20220329-day18:大文件读取解决方法
# 如果文件有很多行
with open('eg.txt',mode='r',encoding="utf-8") as file_object:
for line in file_object:
pass
# 如果文件只有一行
import os
file_size = os.path.getsize("etl_log.txt.txt")
read_size = 0
with open('etl_log.txt.txt', 'rb') as file_object:
while read_size < file_size:
data = file_object.read(1)
read_size += len(data)