Commit 2e133e99 by BellCodeEditor

save project

parent b1bc6149
Showing with 7 additions and 7 deletions
...@@ -9,17 +9,17 @@ file1.close() ...@@ -9,17 +9,17 @@ file1.close()
with open(r"C:\Users\huawei\Desktop\book.txt","a",encoding='utf-8')as file1: with open(r"C:\Users\huawei\Desktop\book.txt","a",encoding='utf-8')as file1:
file1.write('李文2:9本\n') file1.write('李文2:9本\n')
file1.write('张伟2:16本\n') file1.write('张伟2:16本\n')
aaa=""
with open(r"C:\Users\huawei\Desktop\book.txt","r",encoding='utf-8')as file1: with open(r"C:\Users\huawei\Desktop\book.txt","r",encoding='utf-8')as file1:
for data in file1: for data in file1:
if '李文2:9本\n' in data: if '李文2:9本\n' in data:
print("在") data=data.replace('李文2:9本\n','李文2:10本\n')
aaa+=data
if '张伟2:16本\n' in data: if '张伟2:16本\n' in data:
print("在") data=data.replace('张伟2:16本\n','张伟2:15本\n')
aaa+=data
with open(r"C:\Users\huawei\Desktop\book.txt","w",encoding='utf-8')as file1:
file1.write(aaa)
......
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