From 853ea0db59623eead7faac5eef218c2f5ad5c0d3 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 10 Apr 2021 11:16:14 +0800 Subject: [PATCH] save project --- 02.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/02.py b/02.py index 65822ab..443ab33 100644 --- a/02.py +++ b/02.py @@ -1,9 +1,17 @@ + +newdata="" with open(r"C:\Users\Administrator\Desktop\wuzi.txt","r",encoding="utf-8") as file: for data in file: - if "小强:10本" in data: - print("小强数据在文件中") - if "小兰:12本" in data: - print("小兰数据在文件中") - else: - print("数据不在文件中") - break \ No newline at end of file + if "小强:10本" in data: + data=data.replace("10","11") + + newdata += data + + +with open(r"C:\Users\Administrator\Desktop\wuzi.txt","w",encoding="utf-8") as file: + file.write(newdata) + + +with open(r"C:\Users\Administrator\Desktop\wuzi.txt","r",encoding="utf-8") as file: + a=file.read() + print(a) \ No newline at end of file -- libgit2 0.25.0