python指定分隔符来分割文件
1 import re 2 p = re.compile('AAAAAAAA',re.S) 3 f = open(r"D:\test\oldfile.txt","r").read() 4 paralist = p.split(f) 5 total_num = len(paralist) 6 for paraindex in range(total_num): 7 filewrite=file( r"D:\test\\" + str(paraindex) + ".txt",'w') 8 filewrite.writelines(paralist[paraindex]) 9 filewrite.close()