比较简单的在pycharm上跑的脚本
1 #_*_coding:utf-8_*_ 2 3 #普通版 4 file = open("oldfile.txt","r",newline='\r\n') 5 newfile = open("newfile.txt",'w',) 6 7 while True: 8 lines = file.readlines(100000) 9 if not lines: 10 break 11 for line in lines: 12 newfile.write(line.replace('\r\n',u'|0000|模拟成功\r\n')) 13 14 file.close() 15 newfile.close() 16 17 18 19 20 #加强版 21 22 with open('oldfile.txt','r',newline='\r\n') as oldfile, open('new.txt','w') as newfile: 23 while True: 24 lines = oldfile.readlines(100000) 25 if not lines: 26 break 27 for i in lines: 28 newfile.write(i.replace('\r\n',u'|0000|模拟成功\r\n'))