提问人:Suriname0 提问时间:6/1/2018 更新时间:6/1/2018 访问量:5721
Python OSError:从大文件读取时地址错误
Python OSError: Bad address when reading from large file
问:
我从使用 Python 3 中的语法创建的文件句柄读取时观察到“错误地址”。OSError
with
有问题的文件是 39G,但我应该有足够的 RAM 来读取整个文件。错误消息使我相信我遇到了某种操作系统限制;我运行的是 CentOS 6.9。谁能帮我了解可能导致这种行为的原因?
该文件在 python 之外是完全可读的,例如在 bash 中使用 or 。head
vim
产生错误的简化代码示例如下所示:
In [2]: with open(filename, 'r', encoding="utf8") as infile:
...: infile.read()
...:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-3f216811bec7> in <module>()
1 with open(filename, 'r', encoding="utf8") as infile:
----> 2 infile.read()
3
OSError: [Errno 14] Bad address
答: 暂无答案
评论
mmap
read
bytes
str
grep
head
read()
read
1<<31
read()