Commit b488966b by BellCodeEditor

save project

parent 7e3a2ff3
Showing with 19 additions and 1 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
# 写入同学们的捐赠明细:'小兰:12本
fut=open("C:\\Users\\Administrator\\Desktop\\mzl.txt","w",encoding="utf-8")
fut.write("小兰:12本\n")
fut.write("李明:12本\n")
fut.write("小强:12本\n")
fut.close()
s=""
with open("C:\\Users\\Administrator\\Desktop\\mzl.txt","r",encoding="utf-8") as fut:
# n=fut.read()
for i in fut:
if "小强:12本" in i:
i=i.replace("小强:12本","小强:11本")
print(i)
s+=i
with open("C:\\Users\\Administrator\\Desktop\\mzl.txt","w",encoding="utf-8") as fut:
fut.write(s)
\ 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