Commit 2c6a3ad4 by BellCodeEditor

save project

parent 2a486f70
Showing with 15 additions and 11 deletions
file=open ("book.txt","r",encoding="utf=8") new_data=""
for data in file: with open ("book.txt","r",encoding="utf=8")
if '小兰:10本'in data: for data in file:
print('在') if '小赤:10本'in data:
else: data=data.replace(_old:'小赤:10本',_new'小赤:20')
print('不在') if '小橙:11本'in data:
if'小强:12本'in data: data=data.replace(_old:'小橙:11本',_new'小橙:21')
print('在') data=data.replace(_old:'小赤:10本',_new'小赤:20')
else: new_ data+data
print('不在') with open ("book.txt","w",encoding="utf=8")as f1
\ No newline at end of file f1.wite(new_data)
with open ("book.txt","w",encoding="utf=8")as f2
a=f2.read()
print(a)
\ 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