Commit bd4071fb by BellCodeEditor

save project

parent b3f65756
Showing with 8 additions and 5 deletions
...@@ -5,17 +5,20 @@ ...@@ -5,17 +5,20 @@
# file1.write('李明:15本\n') # file1.write('李明:15本\n')
# file1.close() # file1.close()
new_i=''
with open(r'C:\Users\Administrator\Desktop\test.txt','r',encoding='utf-8') as file1: with open(r'C:\Users\Administrator\Desktop\test.txt','r',encoding='utf-8') as file1:
# file1.write('小兰:12本\n') # file1.write('小兰:12本\n')
# a=file1.read()i: # a=file1.read()i:
# print(a) # print(a)
for i in file1: for i in file1:
if '小强:10本' in i: if '小强:10本' in i:
print("数据有了") # print("数据有了")
if '小兰:12本' in i: i=i.replace('小强:10本','小强:11本')
print("数据有了") new_i+=i
# if '小兰:12本' in i:
# print("数据有了")
with open(r'C:\Users\Administrator\Desktop\test.txt','w',encoding='utf-8') as file1:
file1.write(new_i)
......
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