Commit 3eb9fc2d by BellCodeEditor

save project

parent ab7a12ac
Showing with 7 additions and 6 deletions
...@@ -10,13 +10,14 @@ with open(r"C:\Users\周子轩\Desktop\test.txt","r",encoding="utf-8") as file: ...@@ -10,13 +10,14 @@ with open(r"C:\Users\周子轩\Desktop\test.txt","r",encoding="utf-8") as file:
a=file.read() a=file.read()
for i in a: for i in a:
if i=="小强:15本": if i=="小强:15本":
print("数据在文件中") #print("数据在文件中")
# if i=="小兰:12本": # if i=="小兰:12本":
# print("数据在文件中") # print("数据在文件中")
new_date=repiace # new_date=replace
for i in a: # for i in a:
if i=="小强:20本": # if i=="小强:20本":
i.repiace("小强:20本","小强:15本") i.replace("小强:20本","小强:15本")
new_date+=i new_date+=i
with open(w"C:\Users\周子轩\Desktop\test.txt","r",encoding="utf-8") as filel: with open(r"C:\Users\周子轩\Desktop\test.txt","w",encoding="utf-8") as filel:
file.write(new_date)
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