오랫동안 사용하지 않은 프로그램이 있는데 피클 형식으로 정보가 저장되어 있습니다. 이 정보를 얻고 싶습니다. 지금 이 프로그램을 실행하려고 했지만 다음 오류가 발생합니다.
AttributeError: 'class_info_image_one' object has no attribute '__dict__'
class_info_image_one
명명된 튜플입니다.
여기에서 이것을 찾았습니다: Pickle 크로스 플랫폼 __dict__ 속성 오류
그렇다면 이 프로그램은 어떤 버전의 파이썬에서 실행되어야 할까요? 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 버그에 대한 토론에 따르면 __dict__
Python 3.2 및 3.3에 있는 피클 의 깨진 부분 이 3.3.2에서 수정되었습니다. 분명히 동일한 버전에서 피클 해제를 방지하지 못했습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다