Home >Backend Development >Python Tutorial >Python simply reads large files
The example in this article describes how to simply read large files in Python. Share it with everyone for your reference, the details are as follows:
The method used by Python to read large files (GB level) is very simple:
with open(...) as f: for line in f: <do something with line>
For example:
with open(filepath,'r') as infile: for line in infile: print line
Everything is handled by the python interpreter, the reading efficiency is very high, and it takes up less resources.
stackoverflow reference link: How to read large file, line by line in python - Stack Overflow
For more articles related to python's simple reading of large files, please pay attention to the PHP Chinese website!