无法解开旧的d

2024-04-19 04:01:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个很长时间没用的程序,它的信息以pickle格式存储。我想把这个信息拿出来。我现在试图运行此程序,但出现以下错误:

AttributeError: 'class_info_image_one' object has no attribute '__dict__'

class_info_image_one是一个namedtuple。你知道吗

找到此处引用的:Pickle cross platform __dict__ attribute error

那么,这个程序应该在哪个版本的python上运行呢?我试过python3.7和python3.1,两个版本都有相同的错误。你知道吗

尝试使用python 2.7,出现以下错误:

ValueError: unsupported pickle protocol: 3

这是我正在使用的代码,我删除了所有不必要的内容:

import os
import pickle

from collections import deque, namedtuple


class_info_image_one = namedtuple('class_info_image_one', 'md5 extension id tags rating source has_notes has_sample parent_id has_children created_at status author creator_id width height file_size has_comments score')


if os.path.isfile('info_image.pickle'):
    with open('info_image.pickle', 'rb') as lolfile:
        info_image = pickle.load( lolfile )

Tags: imageimport程序版本info信息id错误
1条回答
网友
1楼 · 发布于 2024-04-19 04:01:51

根据您链接的关于Python bug的讨论,pickle中损坏的__dict__存在于python3.2和3.3中,并在3.3.2中修复。显然,这并不能阻止在同一版本中取消勾选。你知道吗

相关问题 更多 >