Commit eec36fad by BellCodeEditor

save project

parent 7988f48f
Showing with 6 additions and 1 deletions
...@@ -4,7 +4,12 @@ ...@@ -4,7 +4,12 @@
#with open(r"D:\abc.txt","a",encoding="utf-8") as file: #with open(r"D:\abc.txt","a",encoding="utf-8") as file:
# file.write('小强:10本\n') # file.write('小强:10本\n')
new_data=""
with open(r"D:\abc.txt","r",encoding="utf-8") as file: with open(r"D:\abc.txt","r",encoding="utf-8") as file:
for data in file: for data in file:
if "小强:10本" in data: if "小强:10本" in data:
print('数据在其中') data=data.replace("小强:10本","小强:11本")
new_data+=data
with open(r"D:\abc.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