Commit 86b00659 by BellCodeEditor

save project

parent 2599831c
Showing with 8 additions and 0 deletions
new_data=''
with open(r'C:\Users\78187\Desktop\book.txt','r',encoding='utf-8') as filel: with open(r'C:\Users\78187\Desktop\book.txt','r',encoding='utf-8') as filel:
for data in filel: for data in filel:
if '小强:10本' in data: if '小强:10本' in data:
...@@ -5,5 +6,12 @@ with open(r'C:\Users\78187\Desktop\book.txt','r',encoding='utf-8') as filel: ...@@ -5,5 +6,12 @@ with open(r'C:\Users\78187\Desktop\book.txt','r',encoding='utf-8') as filel:
if '小兰:12本' in data: if '小兰:12本' in data:
print("小兰数据在文件中") print("小兰数据在文件中")
new_data +=data
with open(r'C:\Users\78187\Desktop\book.txt','w',encoding='utf-8') as filel:
filel.write(new_data)
with open(r'C:\Users\78187\Desktop\book.txt','r',encoding='utf-8') as filel:
a=filel.read()
print(a)
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