Commit 7594dbe9 by BellCodeEditor

save project

parent b73a39d5
Showing with 17 additions and 2 deletions
...@@ -4,11 +4,25 @@ ...@@ -4,11 +4,25 @@
# with open(r'C:\Users\Administrator\Desktop\ardunio素材\test.txt','a',encoding='utf-8') as file1: # with open(r'C:\Users\Administrator\Desktop\ardunio素材\test.txt','a',encoding='utf-8') as file1:
# file1.write('小强:10本\n') # file1.write('小强:10本\n')
# file1.write('小明:15本\n') # file1.write('小明:15本\n')
# with open(r'C:\Users\Administrator\Desktop\ardunio素材\test.txt','r',encoding='utf-8') as file1:
# for date in file1:
# if '小强:10本' in date:
# print('在')
# if '小兰:12本' in date:
# print('在')
new_date=''
with open(r'C:\Users\Administrator\Desktop\ardunio素材\test.txt','r',encoding='utf-8') as file1: with open(r'C:\Users\Administrator\Desktop\ardunio素材\test.txt','r',encoding='utf-8') as file1:
for date in file1: for date in file1:
if '小强:10本' in date: if '小强:10本' in date:
print('在') date=date.replace('小强:10本','小强:15本')
if '小兰:12本' in date: if '小兰:12本' in date:
print('在') date=date.replace('小兰:12本','小兰:15本')
new_date +=date
with open(r'C:\Users\Administrator\Desktop\ardunio素材\test.txt','a',encoding='utf-8') as file1:
file1.write(new_date)
with open(r'C:\Users\Administrator\Desktop\ardunio素材\test.txt','a',encoding='utf-8') as file1:
a=file1.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