# read方法默认会把文件的所有内容一次性读到内存
file = open("readme", mode="r", encoding="utf-8")
while True:
text = file.readline() # readline适合读取大文件
# 判断是否读取到内容
if not text:
break
print(text)
file.close()
python分行读取文件
最新推荐文章于 2024-07-05 09:40:43 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)