今天遇到一个学员,问道无法打开spydata文件。我很少遇到这种文件,我搜索一下,找到了解决方案,分享给大家。
# a naive and incomplete demonstration on how to read a *.spydata file
import pickle
import tarfile
# open a .spydata file
filename = 'test.spydata'
tar = tarfile.open(filename, "r")
# extract all pickled files to the current working directory
tar.extractall()
extracted_files = tar.getnames()
for f in extracted_files:
if f.endswith('.pickle'):
with open(f, 'rb') as fdesc:
data = pickle.loads(fdesc.read())
# or use the spyder function directly:
from spyderlib.utils.iofuncs import load_dictionary
data_dict = load_dictionary(filename)
版权声明:文章来自公众号(python风控模型),未经许可,不得抄袭。遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。