>>> fn = open('E:/西方哲学史.txt').read()
>>> fn = fn.replace('。','。\t\r\n')
>>> s = open('E:/西方哲学史分句.txt','w')
>>> fn = fn.replace('。','。\t\r\n')
>>> s = open('E:/西方哲学史分句.txt','w')
>>> s = s.write(fn)
想要给每个句子添加,编号 = =,怎么办?
>>> import re
>>> def createid(matchobject,no=[0]):
... no[0]+=1
... return "[%d]"%no[0]
...
>>> text = "★A child is a human being who is not yet an adult.★A child is a human being who is not yet an adult.★A child is a human being who is not yet an adult."
>>> text=re.sub("★",createid,text)
>>> print(text)
[1]A child is a human being who i