Commit 11a676f5 by BellCodeEditor

save project

parent 6b6db531
Showing with 7 additions and 5 deletions
......@@ -2,10 +2,12 @@
# with open(r'C:\Users\34353\Desktop\txt1.txt','a',encoding='utf-8') as file1:
# file1.write('小兰:12本\n小丽:11本\n李文:9本\n张伟:16本')
# file1.write('\n小强:12本\n李明:15\n')
a =''
with open(r'C:\Users\34353\Desktop\txt1.txt','r',encoding='utf-8') as file1:
for data in file1:
if '小强:12本' in data:
print("小强在文件中")
if '小兰:12本' in data:
print('小兰在文件中')
\ No newline at end of file
data = data.replace("小强:12本",'小强:11本')
a+=data
with open(r'C:\Users\34353\Desktop\txt1.txt','w',encoding='utf-8') as file1:
file1.write(a)
\ No newline at end of file
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