From 86b006590afdb02a43d1002609e4fe0643532da2 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 10 Sep 2023 11:14:14 +0800 Subject: [PATCH] save project --- 1.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/1.py b/1.py index c82d2e4..89644ca 100644 --- a/1.py +++ b/1.py @@ -1,3 +1,4 @@ +new_data='' with open(r'C:\Users\78187\Desktop\book.txt','r',encoding='utf-8') as filel: for data in filel: if '小强:10本' in data: @@ -5,5 +6,12 @@ with open(r'C:\Users\78187\Desktop\book.txt','r',encoding='utf-8') as filel: if '小兰:12本' in data: 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) - \ No newline at end of file -- libgit2 0.25.0