From 8695778323e5c36d5579293b185796b1ef059d0d Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 4 Sep 2022 11:51:12 +0800 Subject: [PATCH] save project --- diy.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/diy.py b/diy.py index 3b1b059..e17c5b2 100644 --- a/diy.py +++ b/diy.py @@ -4,10 +4,18 @@ #fell.close() - +New_data="" with open(r"C:\Users\admin\Desktop\谁敢删谁是SB\text.txt","r",encoding="utf-8") as fell: for data in fell: if '小强:10本' in data: - print("数据在文件中") + data = data.replace('小强:10本','小强:11本') + New_data+=data if '小兰:12本' in data: - print("数据在文件中") \ No newline at end of file + data=data.replace('小兰:12本','小兰:14本') + New_data+=data + +with open(r"C:\Users\admin\Desktop\谁敢删谁是SB\text.txt","w",encoding="utf-8") as fell: + fell.write(New_data) +with open(r"C:\Users\admin\Desktop\谁敢删谁是SB\text.txt","r",encoding="utf-8") as fell: + a=fell.read() + print(a) \ No newline at end of file -- libgit2 0.25.0