本文實例講述了python簡單讀取大檔案的方法。分享給大家供大家參考,具體如下:
Python讀取大檔案(GB等級)採用的辦法很簡單:
with open(...) as f: for line in f: <do something with line>
例如:
with open(filepath,'r') as infile: for line in infile: print line
一切交給python解釋器處理,讀取效率很高,佔用資源少。
stackoverflow 參考連結:How to read large file, line by line in python - Stack Overflow
更多python簡單讀取大檔案相關文章請關注PHP中文網!