Commit 7284e6cb by BellCodeEditor

auto save

parent a27e5c75
Showing with 15 additions and 0 deletions
......@@ -4,3 +4,17 @@
# s.close()
# with open(r"C:\Users\Administrator\Desktop\test.txt",'a',encoding='utf-8') as a:
# a.write('\n小强:10本\n李明:15本\n')
b = ''
with open(r"C:\Users\Administrator\Desktop\test.txt",'r',encoding='utf-8') as a:
for i in a:
if '小强:10本' in i:
i = i.replace('小强:10本','小强:11本')
if '小兰:12本' in i:
i = i.replace('小兰:12本','小兰:14本')
b+=i
with open(r"C:\Users\Administrator\Desktop\test.txt",'w',encoding='utf-8') as a:
a.write(b)
with open(r"C:\Users\Administrator\Desktop\test.txt",'r',encoding='utf-8') as a:
print(a.read())
\ 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