Commit 354b78ca by BellCodeEditor

save project

parent f3d33f66
Showing with 16 additions and 4 deletions
......@@ -4,7 +4,20 @@ filel.write('小美:12本\n')
filel.write('小丽:11本\n')
filel.write('李文:9本\n')
filel.close()
with open(r'C:\\Users\\Public\\Desktop\\test.txt','r',encoding='utf-8')as file1:
new_data:''
with open(r'C:\\Users\\Public\\Desktop\\test.txt','w'encoding='utf-8') as file1:
for data in filel:
if'小丽:11本'in data:
print('数据在文件中')
\ No newline at end of file
if'小丽:11本' in data:
data=data.replace('小丽:11本','小丽:12本')
new_data+=data
with open(r'C:\\Users\\Public\\Desktop\\test.txt','w'encoding='utf-8') as file1:
filel.write(new_data)
with open(r'C:\\Users\\Public\\Desktop\\test.txt','r'encoding='utf-8') as file1:
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