Commit ca07ad55 by BellCodeEditor

save project

parent 520be605
Showing with 5 additions and 2 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、 # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、
new_a = ''
with open(r'C:\Users\86183\Desktop\test.txt','r',encoding='utf-8')as a: with open(r'C:\Users\86183\Desktop\test.txt','r',encoding='utf-8')as a:
for b in a: for b in a:
if '刘某某:100本'in b: if '刘某某:100本'in b:
b=b.replace('刘某某:100本','刘某某:15本') b=b.replace('刘某某:100本','刘某某:15本')
print(b) new_a +=b
with open(r'C:\Users\86183\Desktop\test.txt','w',encoding='utf-8')as a:
a.write(new_a)
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