本文实例讲述了python简单读取大文件的方法。分享给大家供大家参考,具体如下:
Python读取大文件(GB级别)采用的办法很简单:
with open(...) as f: for line in f: <do something with line>
立即学习“Python免费学习笔记(深入)”;
例如:
with open(filepath,'r') as infile: for line in infile: print line
立即学习“Python免费学习笔记(深入)”;
一切都交给python解释器处理,读取效率很高,且占用资源少。
stackoverflow参考链接:How to read large file, line by line in python - Stack Overflow
更多python简单读取大文件相关文章请关注PHP中文网!
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号