Commit a10f5254 by BellCodeEditor

save project

parent 7762c274
Showing with 9 additions and 4 deletions
......@@ -3,8 +3,14 @@ filter=open(r'C:\Users\Administrator\Desktop\test.txt','w',encoding='utf-8')
filter.write('小兰: 12本')
filter.close()
with open(r'C:\Users\Administrator\Desktop\test.txt','a',encoding='utf-8') as file:
filter.write("小强:13本")
file.write("小强:10本")
new_data=''
with open(r'C:\Users\Administrator\Desktop\test.txt','r',encoding='utf-8') as file:
for data in file:
if "小强:13本" in data:
print("数据在")
\ No newline at end of file
if "小强:10本" in data:
data= data.replace('小强:10本','小强:11本')
new_data+=data
with open(r'C:\Users\Administrator\Desktop\test.txt','r',encoding='utf-8') as file:
filel.write(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