Commit 2cb61cdd by BellCodeEditor

save project

parent 8e695158
Showing with 7 additions and 2 deletions
......@@ -8,12 +8,17 @@
# file.close()
#with open(r'C:\Users\bellcode\Desktop\book.txt','a',encoding='utf—8')as file:
#file.write('小强,12本\n李明,15本')
new_data=''
with open(r'C:\Users\bellcode\Desktop\book.txt','r',encoding='utf—8')as file:
for data in file:
if '小强,12本' in data:
print('yes,小强!')
data=data.replace('小强,12本''小强,11本')
if '小兰,12本' in data:
print('yes,小兰!')
data=data.replace('小兰,12本''小兰,14本')
new_data+=data
with open(r'C:\Users\bellcode\Desktop\book.txt','w',encoding='utf—8')as file:
file.write(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