Commit bc2abcc3 by BellCodeEditor

save project

parent 9981d259
Showing with 7 additions and 1 deletions
...@@ -7,9 +7,14 @@ ...@@ -7,9 +7,14 @@
# f=open(r'D:\test.txt','r',encoding='utf-8') # f=open(r'D:\test.txt','r',encoding='utf-8')
# # f.write('张伟:16本\n') # # f.write('张伟:16本\n')
# f.close() # f.close()
new_data=''
with open(r'D:\test.txt','r',encoding='utf-8') as f: with open(r'D:\test.txt','r',encoding='utf-8') as f:
# f.write('小明:22本') # f.write('小明:22本')
# ee # ee
for i in f: for i in f:
if '小明:22本' in i : if '小明:22本' in i :
print("有") # print("有")
i=i.replace('小明:22本','小明:29本')
new_data+=i
with open(r'D:\test.txt','w',encoding='utf-8') as f:
f.write(new_data)
\ 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