Commit 7a003fee by BellCodeEditor

save project

parent f9a78598
Showing with 13 additions and 2 deletions
# 写入同学们的捐赠明细:''小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本a
new_a=''
with open(r'C:\Users\EDZ\Desktop\新建文件夹\text.tst1','r',encoding='utf-8') as a:
for b in a:
if '小强:12本' in b:
print('数据在文件夹中')
if '小强:12本' in a:
a=a.replace('小强:12本','小强:11本')
if '小兰:12本' in a:
a=a.replace('小兰:12本','小兰:14本')
new_a +=a
with open(r'C:\Users\EDZ\Desktop\新建文件夹\text.tst1','r',encoding='utf-8') as a:
a.write(new_a)
with open(r'C:\Users\EDZ\Desktop\新建文件夹\text.tst1','r',encoding='utf-8') as a:
a=b.read()
print(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