Commit 86957783 by BellCodeEditor

save project

parent cf48a37c
Showing with 12 additions and 4 deletions
......@@ -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
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