Commit c9e149bc by BellCodeEditor

save project

parent 054d3cd9
Showing with 9 additions and 5 deletions
...@@ -12,13 +12,17 @@ ...@@ -12,13 +12,17 @@
#file.close() #file.close()
new_data=''
with open(r'C:\Users\admin\Desktop\111\222.txt','r',encoding='utf-8')as file: with open(r'C:\Users\admin\Desktop\111\222.txt','r',encoding='utf-8')as file:
for data in file: for data in file:
if '李文:9本' in data: if'李文:9本' in data:
data=data.replace('李文:9本','李文:11本')
print('数据在文件中') new_data +=data
with open(r'C:\Users\admin\Desktop\111\222.txt','w',encoding='utf-8')as file:
file.write(new_data)
print()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment