#打开文件
flit=open('my_txt.txt','r',encoding='utf-8')
#读取文件
f=flit.read()
print("读取全部文件内容:\n",f)
#读取指定的字节数量
l=flit.read(20)
print("读取20个字节数:\n",l)
#注意,如果再出读取文件,会接着上次读取结束开始读取
#将文件已行形式转为列表
fl=flit.readlinpes()
print(fl,type(fl))
#readline()方法,只读取一行文本
fi=flit.readline()
print("只读取一行文字:\n",fi)