【问题标题】:loading big .npy file causing python to stop working加载大的 .npy 文件导致 python 停止工作
【发布时间】:2019-01-18 09:37:30
【问题描述】:

我正在尝试加载一个很大 (6GB) 的 .npy 文件,但我收到了 Python has stopped working 错误。关于如何解决这个问题的任何建议?

【问题讨论】:

    标签: python python-3.x numpy io


    【解决方案1】:

    您可以对更大的文件使用缓冲,例如:

    with open("bigfile.npy","r",buffering=1000) as f:
        contents=f.read()
        #do something with the fist n lines of file at a time
    

    这不会完全打开整个文件,而只会打开您在缓冲 arg 中指定为整数的数量(您可以根据您正在使用的系统决定您想要什么)并且系统不会停止工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-30
      • 1970-01-01
      • 2014-07-29
      • 1970-01-01
      • 2020-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多