Commit cc35df2f by BellCodeEditor

auto save

parent 6f36511e
Showing with 19 additions and 0 deletions
# file1 = open(r"C:\Users\Administrator\Desktop\book.txt",'r',encoding = 'utf-8')
# file1.write('1号:10本\n')
# file1.write('2号:14本\n')
# file1.write('3号:8本\n')
# file1.write('4号:3本\n')
# file1.close()
new_data = ' '
with open(r"C:\Users\Administrator\Desktop\book.txt",'r',encoding = 'utf-8') as file1:
for data in file1:
if '1号:10本' in data:
print('1号数据在文件中')
if '2号:14本' in data:
print('2号数据在文件中')
with open(r"C:\Users\Administrator\Desktop\book.txt",'w',encoding = 'utf-8') as file1:
file1.write(new_data)
with open(r"C:\Users\Administrator\Desktop\book.txt",'r',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