Commit 8e3055b9 by BellCodeEditor

save project

parent 0d74769e
Showing with 16 additions and 0 deletions
newi=""
with open(r"C:\Users\mk\Desktop\新建文件夹\text.txt","w",encoding="utf-8")as file:
file.write("小明:12本\n")
with open(r"C:\Users\mk\Desktop\新建文件夹\text.txt","a",encoding="utf-8")as file:
file.write("小李:11本\n")
file.write("小马:14本\n")
with open(r"C:\Users\mk\Desktop\新建文件夹\text.txt","r",encoding="utf-8")as file:
for i in file:
if "小明:12本"in i:
i=i.replace("小明:12本","小明:10本")
newi+=i
with open(r"C:\Users\mk\Desktop\新建文件夹\text.txt","w",encoding="utf-8")as file:
file.write(newi)
\ 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