Commit 062b92fa by BellCodeEditor

save project

parent 7913f005
Showing with 11 additions and 2 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
new_data=" "
filel=open(r'C:\Users\Administrator\Desktop\book.txt','r',encoding='utf-8')
for data in filel:
if '小强:10' in data:
print('小强在数据中')
data=data.replace('小强:10','小强:11')
if '小兰:12' in data:
print('小兰在数据中')
data=data.replace('小兰:12','小兰:14')
new_data +=data
filel=open(r'C:\Users\Administrator\Desktop\book.txt','r',encoding='utf-8')
filel.write(new_data)
filel=open(r'C:\Users\Administrator\Desktop\book.txt','r',encoding='utf-8')
a=filel.read()
filel.close()
\ 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