Commit 35dfddc4 by BellCodeEditor

save project

parent f4097c20
Showing with 15 additions and 0 deletions
new_data=""
with open(r'C:\Users\makcoo\Documents\lesson12-2\text.txt','r',encoding='utf-8') as a:
a.read()
for data in a:
if data == '小强:12本':
print(data)
data.replace('小强:12本','小强:11本')
new_data=new_data+data
with open(r'C:\Users\makcoo\Documents\lesson12-2\text.txt','w',encoding='utf-8') as a:
a.write(new_data)
a.write('小强:12本\n')
a.write('李明:10本\n')
小强:12本
李明:15本
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