Commit db347f45 by BellCodeEditor

auto save

parent b740f4ed
Showing with 7 additions and 4 deletions
......@@ -2,8 +2,8 @@
#file1=open(r'C:\Users\Makcoo-Bellcode\Desktop\book.txt','w',encoding='utf-8')
#file1.write("小兰:12本\n小丽:11本\n李文:9本\n张伟:16本")
#file1.close()
#with open(r'C:\Users\Makcoo-Bellcode\Desktop\book.txt','a',encoding='utf-8')as file:
# file.write("小兰:12本\n小丽:11本\n李文:9本\n张伟:16本")
with open(r'C:\Users\Makcoo-Bellcode\Desktop\book.txt','w',encoding='utf-8')as file:
file.write("小强:10本\n小兰:12本\n小丽:11本\n李文:9本\n张伟:16本")
new_file=''
with open(r'C:\Users\Makcoo-Bellcode\Desktop\book.txt','r',encoding='utf-8')as file:
for data in file:
......@@ -13,4 +13,7 @@ with open(r'C:\Users\Makcoo-Bellcode\Desktop\book.txt','r',encoding='utf-8')as f
data=data.replace('小兰:12本','小兰:14本')
new_file+=data
with open(r'C:\Users\Makcoo-Bellcode\Desktop\book.txt','w',encoding='utf-8')as file:
file.write(new_file)
\ No newline at end of file
file.write(new_file)
with open(r'C:\Users\Makcoo-Bellcode\Desktop\book.txt','r',encoding='utf-8')as file:
a=file.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