Commit 7b5f29c1 by BellCodeEditor

save project

parent dfab72ab
Showing with 14 additions and 0 deletions
new_date=''
with open(r'C:\Users\Administrator\Desktop\test.txt','w',encoding='utf-8') as file:
file.write('小兰:12本\n')
with open(r'C:\Users\Administrator\Desktop\test.txt','a',encoding='utf-8') as file:
file.write('小明:11本\n')
file.write('小强:14本\n')
with open(r'C:\Users\Administrator\Desktop\test.txt','r',encoding='utf-8') as file:
for i in file:
if '小明:11本' in i:
i=i.replace('小明:11本','小明:12本')
new_date+=i
with open(r'C:\Users\Administrator\Desktop\test.txt','w',encoding='utf-8') as file:
file.write(new_date)
\ 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