Commit 4a2cb4bd by BellCodeEditor

save project

parent 409d3183
Showing with 17 additions and 4 deletions
......@@ -5,8 +5,20 @@
#file1.write('李文:9本')
#file1.write('张伟:16本')
#file1.close()
with open(r'C:\Users\Administrator\test.txt','r',encoding='utf-8')as
file1:
#
#file1:
# for date in file1:
# if '小丽:11本'in date:
# print("数据在文件中")
new_date=''
with open(r'C:\Users\Administrator\test.txt','w',encoding='utf-8')as file1:
for date in file1:
if '小丽:11本'in date:
print("数据在文件中")
if '小强:10本'in date:
date=date.replace('小强:10本','小强:11本')
new_date+ =date
with open(r'C:\Users\Administrator\test.txt','w',encoding='utf-8')as file1:
file1.write(new_date)
\ 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