Commit 95ff1704 by BellCodeEditor

auto save

parent a8d02629
Showing with 38 additions and 0 deletions
#写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
# a=open(r"C:\Users\EDZ\Desktop\text.txt",'w',encoding='UTF-8')
# a.write('小兰:12本')
# a.write('小丽:11本')
# a.write('李文:9本')
# a.write('张伟:16本')
# a.close()
# a=open(r"C:\Users\EDZ\Desktop\text.txt",'a',encoding='UTF-8')
# a.write('小强:12本')
# a.write('李明:15本')
# a.close()
new_data=''
a=open(r'C:\Users\EDZ\Desktop\text.txt','r',encoding='UTF-8'):
for data in file1:
if'小强:12本'in data:
data=a.replace('小强:12本','小强:11本')
if''小兰:12''in data
data=a.replace('小兰:12本','小兰:14本')
new_data+=data
a.close()
with open(r'C:\Users\EDZ\Desktop\text.txt','w',encoding='UTF-8') as file1:
file1.write(new.data)
# for i in a:
# if "小强:12本" in i:
# print("在")
# else:
# print("不在")
# if "小兰:12本" in i:
# print("在")
# else:
# print("不在")
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