Python-文件-读取整理

1 按行读取文本文件

1
2
3
4
file_path = 'xxx'
with open(file_path) as f:
for line in f.readlines():
print(line)

open详解