Commit a556c8ad by BellCodeEditor

save project

parent 2d42e4bc
Showing with 8 additions and 1 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
file = open(r"C:\Users\EDZ\Desktop\新建文本文档.txt","r",encoding="utf-8") file = open(r"C:\Users\EDZ\Desktop\新建文本文档.txt","r",encoding="utf-8")
nw=""
for data in file: for data in file:
print(data) if "张伟:16本"in data:
data=data.replace("张伟:16本","张伟:1000本")
nw+=data
file.close()
file = open(r"C:\Users\EDZ\Desktop\新建文本文档.txt","w",encoding="utf-8")
file.write(nw)
file.close() file.close()
\ 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