Commit e03c56b9 by BellCodeEditor

save project

parent a84018ee
Showing with 11 additions and 0 deletions
with open(r"C:\Users\Windows 10\Desktop\book.txt",'w',encoding='utf-8')as a:
a.write("小兰:12本\n小强:10本\n小明:8本\n小红:9本")
new_a=''
with open(r"C:\Users\Windows 10\Desktop\book.txt",'r',encoding='utf-8')as a:
for i in a:
if "小强:10本" in i:
i=i.replace("小强:10本","小强:11本")
new_a+=i
with open(r"C:\Users\Windows 10\Desktop\book.txt",'w',encoding='utf-8')as a:
a.write(new_a)
\ 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