Python Pickle:什么会导致堆栈索引超出范围错误?

发布于 2024-09-05 14:55:01 字数 441 浏览 5 评论 0原文

我收到此错误:

  File "C:\Python26\lib\pickle.py", line 1374, in loads
    return Unpickler(file).load()
  File "C:\Python26\lib\pickle.py", line 858, in load
    dispatch[key](self)
  File "C:\Python26\lib\pickle.py", line 1075, in load_obj
    k = self.marker()
  File "C:\Python26\lib\pickle.py", line 874, in marker
    while stack[k] is not mark: k = k-1
IndexError: list index out of range

为什么会发生这种情况?

I'm getting this error:

  File "C:\Python26\lib\pickle.py", line 1374, in loads
    return Unpickler(file).load()
  File "C:\Python26\lib\pickle.py", line 858, in load
    dispatch[key](self)
  File "C:\Python26\lib\pickle.py", line 1075, in load_obj
    k = self.marker()
  File "C:\Python26\lib\pickle.py", line 874, in marker
    while stack[k] is not mark: k = k-1
IndexError: list index out of range

Why could this be happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剑心龙吟 2024-09-12 14:55:01

“文件损坏”是一般性的解释;一个最可能的原因是您忘记将文件(在 Windows 中)打开为 'rb' (“读取二进制文件”),并且酸洗是使用二进制协议(即除旧协议之外的任何协议)完成的。 ,慢速默认协议 0,仅限 ascii,基本上仅出于遗留目的而存在,会生成更大的文件,并且有一些限制)。

A "damaged file" is the general explanation; single most likely cause is that you forgot to open the file (in Windows) as 'rb' ("read binary") and the pickling was done with a binary protocol (i.e., any protocol except the old, slow default protocol 0, ascii only, that basically exists only for legacy purposes, makes larger files, and has several limitations).

牛↙奶布丁 2024-09-12 14:55:01

回答:我试图在 Google App Engine 模型的未初始化字段上调用 ​​pickle.loads()

Answer: I was trying to call pickle.loads() on the uninitialized field of a Google App Engine model.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文