Commit b7d139e4 by BellCodeEditor

save project

parent d3284023
Showing with 11 additions and 12 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
ij=open(r'C:\Users\29018\Desktop\uxcucya.txt','w',encoding='utf-8')
ij.write('小兰:12本,小丽:11本,李文:9本,张伟:16本')
ij.write('小兰:12本''小丽:11本''李文:9本''张伟:16本')
ij.close()
ij=open(r'C:\Users\29018\Desktop\uxcucya.txt','a',encoding='utf-8')
ij.write('小张:122本')
ij.close()
new_data=''
ij=open(r'C:\Users\29018\Desktop\uxcucya.txt','r',encoding='utf-8')
for i in ij:
if '小兰' in i:
data=i.replace('小兰','小灰')
new_data=new_data+data
with open(r'C:\Users\29018\Desktop\uxcucya.txt','r',encoding='utf-8')as file:
for i in file:
if "小王" in i:
print("在")
else:
print('不在')
ij=open(r'C:\Users\29018\Desktop\uxcucya.txt','w',encoding='utf-8')
ij.write(new_data)
ij.close()
print("不在")
\ 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