【发布时间】:2015-03-31 09:27:04
【问题描述】:
我有一组文件组成如下:
Product: Name
Description: description of product
我只想提取名称和描述的内容,而不提取 'Product:' 和 'Description:'。为此,我这样做:
div = re.split('Product:\s+|Description:\s+', contentOfFile)
问题是我得到了一个由 3 个元素组成的表格,而不是 2 个元素,开头有一个 ' ' (空格)。我不知道是否总是考虑空间,因为我只想在这种情况下获得:
["Name","description of product"]
【问题讨论】: