Mixing iteration and read methods would lose data

linux环境下,下图1的操作报错,改成图2的形式即可,在windows下不会报错,运行良好,原因有待探究

ValueError: Mixing iteration and read methods would lose data

Mixing iteration and read methods would lose data_第1张图片

lines = fr.readline()

for line in lines[1:]

对于很大的文档,读取的时候逐行读取,提取想要的部分,防止太大内存不够;

Mixing iteration and read methods would lose data_第2张图片

你可能感兴趣的:(Mixing iteration and read methods would lose data)