Commit 3ccbe350 by BellCodeEditor

auto save

parent 59f687ca
Showing with 20 additions and 0 deletions
with open (r'c:\Users\10839\Desktop\test.txt','w',encoding='utf-8') as file:
with open (r'c:\Users\10839\Desktop\test.txt','w',encoding='utf-8') as file:
file.write('小兰:12本\n小强:15本\n李明:10本\n')
with open (r'c:\Users\10839\Desktop\test.txt','a',encoding='utf-8') as file:
file.write('小王:16本\n')
with open (r'c:\Users\10839\Desktop\test.txt','r',encoding='utf-8') as file:
a=file.read()
#print(a)
with open (r'c:\Users\10839\Desktop\test.txt','r',encoding='utf-8') as file:
new_data=''
for data in file:
if '小王:16本' in data:
data=data.replace('小王:16本','小王:50本')
new_data=new_data+data
print(new_data)
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