Commit 354b78ca by BellCodeEditor

save project

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