在Python中 ,如何处理逐行读取文件进行处理?
就像Bash中的那些行一样:
while read line ; do
echo $line
done < ./input.txt
在Python中,你可以通过一个过程,文件里逐行for像文件中。
with open("./input.txt", "r") as thefile:
for line in thefile:print line
翻译自: https://www.systutorials.com/how-to-process-a-file-line-by-line-in-python/
推荐阅读--