Commit 7edef936 by BellCodeEditor

auto save

parent 0bb31aec
Showing with 15 additions and 7 deletions
# 补充数据的第一种写法:
# file= open(r'\\Mac\Home\Desktop\book.txt','a',encoding='utf-8')
# file.write('小李:10本\n')
# file.write('李白:15本\n')
# file.close()
file= open(r'\\Mac\Home\Desktop\book.txt','r',encoding='utf-8')
a=file.read()
print(a)
file.close()
# file.write('里:10本\n')
# file.write('你:10本\n')
with open(r'\\Mac\Home\Desktop\book.txt','a',encoding='utf-8') as file:
file.write('li:10本\n')
file.write('李明:15本\n')
# with open(r'\\Mac\Home\Desktop\book.txt','r',encoding='utf-8') as file:
# a=file.read()
# print(a)
with open(r'C:\Users\CM\Desktop\book.txt','r',encoding='utf-8') as file1:
for data in file1:
if '小强:10本' in data:
print('小强数据在文件中')
if '小兰:12本'in data:
print('小兰数据在文件中')
\ 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