Commit 0038e2b2 by BellCodeEditor

save project

parent 7c7d2951
Showing with 17 additions and 0 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
with open(r"D:\utf.txt",'w',encoding='utf-8') as s:
s.write('小兰:12本\n')
s.write('小丽:11本\n')
s.write('李文:9本\n')
a=""
with open(r"D:\utf.txt",'r',encoding='utf-8') as s:
#a=s.read()
new_s=""
for a1 in s:
new_s=a1
if '小兰:12本' in a1:
new_s=a1.replace('小兰:12本','小兰:13本')
a+=new_s
print(new_s)
with open(r"D:\utf.txt",'w',encoding='utf-8') as s:
s.write(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