Commit f0f30440 by BellCodeEditor

save project

parent 9761939d
Showing with 12 additions and 5 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' new_data=''
with open('C:\Users\Administrator\Desktop','r',encoding='utf-8')as cj1: with open(r'C:\Users\Administrator\Desktop\book2.txt','r',encoding='utf-8')as cj1:
for data in cj1: for data in cj1:
if '123323' in cj1: if '123' in data:
print('文件中有') data=data.replace('123','456')
\ No newline at end of file new_data+=data
with open(r'C:\Users\Administrator\Desktop\book2.txt','w',encoding='utf-8')as cj1:
cj1.write(new_data)
with open(r'C:\Users\Administrator\Desktop\book2.txt','r',encoding='utf-8')as cj1:
a=cj1.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