Commit 45d1763c by BellCodeEditor

save project

parent d4d241fa
Showing with 18 additions and 2 deletions
...@@ -13,7 +13,24 @@ ...@@ -13,7 +13,24 @@
# file.write("小兰:12本\n") # file.write("小兰:12本\n")
# file.write("小丽:11本\n") # file.write("小丽:11本\n")
# with open(r"D:\test.txt","r",encoding="utf-8") as file:
# for i in file:
# if "小兰:12本" in i:
# print("数据在文本中")
new_date=""
with open(r"D:\test.txt","r",encoding="utf-8") as file: with open(r"D:\test.txt","r",encoding="utf-8") as file:
for i in file: for i in file:
if "小兰:12本" in i: if "小兰:12本" in i:
print("数据在文本中") i=i.replace("小兰:12本","小兰:13本")
\ No newline at end of file # if "小丽:11本" in i:
# i=i.replace("小丽:11本","小丽:14本")
new_date+=i
with open(r"D:\test.txt","w",encoding="utf-8") as file:
file.write(new_date)
with open(r"D:\test.txt","r",encoding="utf-8") as file:
qqq=file.read()
print(qqq)
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