Commit 8317534d by BellCodeEditor

save project

parent b1a75d74
Showing with 2 additions and 2 deletions
...@@ -10,12 +10,12 @@ with open(r"C:\Users\Dell\Desktop\book.txt",'a',encoding='utf-8') as file1: ...@@ -10,12 +10,12 @@ with open(r"C:\Users\Dell\Desktop\book.txt",'a',encoding='utf-8') as file1:
file1.write('李明:15本\n') file1.write('李明:15本\n')
new_data='' new_data=''
with open(r"C:\Users\Dell\Desktop\book.txt",'r',encoding='utf-8') as file1: with open(r"C:\Users\Dell\Desktop\book.txt",'r',encoding='utf-8') as file1:
for i in file1: for data in file1:
if '小强:10本' in file1: if '小强:10本' in file1:
data=data.replace('小强:10本','小强:11本') data=data.replace('小强:10本','小强:11本')
if '小兰:12本' in file1: if '小兰:12本' in file1:
data=data.replace('小兰:12本','小兰:14本') data=data.replace('小兰:12本','小兰:14本')
new_data +=data new_data+=data
with open(r"C:\Users\Dell\Desktop\book.txt",'w',encoding='utf-8') as file1: with open(r"C:\Users\Dell\Desktop\book.txt",'w',encoding='utf-8') as file1:
file1.write(new_data) file1.write(new_data)
with open(r"C:\Users\Dell\Desktop\book.txt",'r',encoding='utf-8') as file1: with open(r"C:\Users\Dell\Desktop\book.txt",'r',encoding='utf-8') as file1:
......
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