Commit d0d81e42 by BellCodeEditor

auto save

parent 5ec53ebb
Showing with 13 additions and 0 deletions
#打开文件的两种方法
#方法1
with open(r'C:\Users\HP\Desktop\bell\文件读写\book.txt','r',encoding='utf-8') as file:
#方法二
file=open(r'C:\Users\HP\Desktop\bell\文件读写\book.txt','r',encoding='utf-8')
#file.close()
#在第一个的基础上,修改
with open(r'C:\Users\HP\Desktop\bell\文件读写\book.txt','r',encoding='utf-8') as file:
a=file.readlines()
for i in a:#用for...in...将每一行的数据遍历一边
print(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