本帖最后由 ivor 于 2016-3-8 21:48 编辑
回复 1# enoone1 - # coding:utf-8
-
- a = False
- wFile = open('new.txt', 'w')
- with open('111.txt', 'r') as file:
- for i in file:
- if a == True:
- a = False
- if i == '\n':
- print('无', file=wFile)
- if i == '新增:\n' or i == '修改:\n':
- a = True
- print(i, end='',file=wFile)
- else:
- print(i, end='',file=wFile)
- wFile.close()
复制代码
|