Commit 8831e563 by BellCodeEditor

save project

parent 850d38c8
Showing with 9 additions and 6 deletions
...@@ -3,10 +3,13 @@ ...@@ -3,10 +3,13 @@
# file1.write("小强:12本\n") # file1.write("小强:12本\n")
# file1.write("李明:15本\n") # file1.write("李明:15本\n")
# file1.close() # file1.close()
n=''
with open(r'C:\Users\Administrator\Desktop\book.txt','r',encoding='utf-8') as file1: with open(r'C:\Users\Administrator\Desktop\book.txt','r',encoding='utf-8') as file1:
for i in file1: for i in file1:
if "小强:12本" in i: if "小强:10本" in i:
print("小强zai") i=i.replace('小强:10本','小强:11本')
if "李明:15本" in i: if "小兰:12本" in i:
print("李明zai") i=i.replace("小兰:12本","小兰:15本")
n+=i
\ No newline at end of file with open(r'C:\Users\Administrator\Desktop\book.txt','w',encoding='utf-8') as file1:
file1.write(n)
\ 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