Commit 0d4af6a4 by BellCodeEditor

save project

parent a8d02629
Showing with 18 additions and 0 deletions
file1=open(r"C:\Users\Administrator\Desktop\text\text.txt","r",encoding="UTF-8")#open
a=file1.readlines()
print(a)
new_data=""
for i in a:
if '小兰' in i:
print('Xiao Lan is in file1')
b= i.replace('小兰:12本','小兰:14本')
new_data+=b
else:
print('Xiao Lan is not in file1')
new_data+=i
file1.close()
print(new_data)
file1=open(r"C:\Users\Administrator\Desktop\text\text.txt","w",encoding="UTF-8")#open
file1.write(new_data)
file1.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