Commit 5d98c383 by BellCodeEditor

save project

parent 7e3a2ff3
Showing with 20 additions and 1 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
t=open(r"C:\Users\双师12\Desktop\text.txt","w",encoding="utf-8")
t.write("小六:15\n小流:10")
t.close()
with open(r"C:\Users\双师12\Desktop\text.txt","w",encoding="utf-8")
t.write("老六:90本")
new_data=""
with open(r"C:\Users\双师12\Desktop\text.txt","r",encoding="utf-8") as t:
a=t.readlines()
print(a)
for i in a:
print(i)
if"老六:本"in i:
print("数据在")
data=data.replace("老六:90","老六:13")
new_data=new_data+data
print(new_data)
while open(r"C:\Users\双师12\Desktop\text.txt","w",encoding="utf-8") as t:
t.writable(new_data)
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