Commit 7b77cd6c by BellCodeEditor

save project

parent bfeef8ad
Showing with 10 additions and 1 deletions
...@@ -8,10 +8,19 @@ sb.close() ...@@ -8,10 +8,19 @@ sb.close()
with open(r"C:\Users\CDLX\Desktop\book1.txt","a",encoding="utf-8") as bs: with open(r"C:\Users\CDLX\Desktop\book1.txt","a",encoding="utf-8") as bs:
bs.write("小强:10本\n") bs.write("小强:10本\n")
bs.write("李明:15本\n") bs.write("李明:15本\n")
new_bs=""
with open(r"C:\Users\CDLX\Desktop\book1.txt","r",encoding="utf-8") as bs: with open(r"C:\Users\CDLX\Desktop\book1.txt","r",encoding="utf-8") as bs:
for i in bs: for i in bs:
if "小强:10本" in i: if "小强:10本" in i:
print("sb") print("sb")
i=i.replace("小强:10本","小强:11本")
if "小兰:12本" in i: if "小兰:12本" in i:
print("bs") print("bs")
i=i.replace("小兰:12本","小兰:14本")
new_bs+=i
new_bs=bs
print(new_bs)
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