无法取消旧数据

Can't unpickle old data

我有一个很久没用过的程序,它的信息以 pickle 格式存储。我想得到这个信息。我现在尝试 运行 这个程序,但我得到这个错误:

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

class_info_image_one 是一个命名元组。

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

那么,python 这个程序应该 运行 哪个版本?我试过 python 3.7 和 python 3.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 )

根据对您链接的 Python 错误的讨论,pickle 中损坏的 __dict__ 存在于 Python 3.2 和 3.3 中,并已在 3.3.2 中修复。显然它并没有阻止在同一个版本中进行 unpickling。