Python Pickle:什么会导致堆栈索引超出范围错误?
我收到此错误:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“文件损坏”是一般性的解释;一个最可能的原因是您忘记将文件(在 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).回答:我试图在 Google App Engine 模型的未初始化字段上调用
pickle.loads()
。Answer: I was trying to call
pickle.loads()
on the uninitialized field of a Google App Engine model.