使用 Pickle 导入文件的问题

发布于 2025-01-12 09:52:48 字数 846 浏览 2 评论 0 原文

我通过在计算机设备上使用 pickle.dump 保存了多个数字。现在,我想使用 pickle.load 将文件加载到我的笔记本电脑上。我写了下面的代码 对于文件名中的文件名:

    with open( path + filename + '.pkl','rb' ) as file:
              linedata = pickle.load(file)
    # plt.close()
    ax = plt.gca()
    
    for m in range( len(M) ):
        line = ax.lines[ m ]
        keyname = filename + '_M=' +  str( M[m] )
        outdict[keyname] = [ line.get_xdata(line), line.get_ydata(line), Linestyle[cnt], Labels[cnt]+ r'$~M={}$'.format(M[m]), Colors[m] ]
        plt.close()
    cnt+=1

但是,会引发以下错误:

AttributeError: Can't get attribute '_picklable_subplot_class_constructor' on

如果有人能解决我的问题,我将不胜感激。

I have saved multiple figures by using pickle.dump on a computer device. Now, I want to load the files on my laptop using pickle.load. I wrote the following code
for filename in filenames:

    with open( path + filename + '.pkl','rb' ) as file:
              linedata = pickle.load(file)
    # plt.close()
    ax = plt.gca()
    
    for m in range( len(M) ):
        line = ax.lines[ m ]
        keyname = filename + '_M=' +  str( M[m] )
        outdict[keyname] = [ line.get_xdata(line), line.get_ydata(line), Linestyle[cnt], Labels[cnt]+ r'$~M={}

However, the following error is raised:

AttributeError: Can't get attribute '_picklable_subplot_class_constructor' on <module 'matplotlib.axes._subplots' from '/Users/saleh/miniforge3/lib/python3.9/site-packages/matplotlib/axes/_subplots.py'>

I would appreciate if anyone can solve my problem.

.format(M[m]), Colors[m] ] plt.close() cnt+=1

However, the following error is raised:

AttributeError: Can't get attribute '_picklable_subplot_class_constructor' on <module 'matplotlib.axes._subplots' from '/Users/saleh/miniforge3/lib/python3.9/site-packages/matplotlib/axes/_subplots.py'>

I would appreciate if anyone can solve my problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文