我有一个大文件,需要从中加载到字符串列表中。每个元素将包含文本,直到数字后面紧跟一个','
例如:
this is some text, value 45789, followed by, 1245, and more text 78965, more random text 5252,
这应该变成:
["this is some text, value 45789", "followed by, 1245", "and more text 78965", "more random text 5252"]
我目前正在做re.sub(r'([0-9]+),','~', <input-string>)
,然后在'〜'上分割(因为我的文件不包含〜),但这将逗号前的数字扔掉了。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句