Commit 29a81b6e by BellCodeEditor

save project

parent a8d02629
Showing with 28 additions and 0 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
#abc=open('C:\\Users\\XMBC\\Desktop\\abcd.txt','w',encoding='utf-8')
#abc.write('小兰:12本')
#abc.write('小丽:11本')
#abc.write('李文:9本')
#abc.write('张伟:9本')
#abc.write('小强:123')
#abc.close()
# abc=open('C:\\Users\\XMBC\\Desktop\\abcd.txt','r',encoding='utf-8')
# for i in abc:
# if'小强:123':
# print('小强在')
# if'小兰:12本':
# print('小兰在')
new_abc=''
abc=open(r'C:\\Users\\XMBC\\Desktop\\abcd.txt','r',encoding='utf-8')
s=abc.read()
if'小强:123' in s:
s.replace('小兰12本','小兰14本')
if'小兰:12本':
s.replace('小强123','小强14本')
abc=open(r'C:\\Users\\XMBC\\Desktop\\abcd.txt','w',encoding='utf-8')
abc.write(s)
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