Commit 2c6a3ad4 by BellCodeEditor

save project

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