模块“pickle"没有属性“dump" [英] module 'pickle' has no attribute 'dump'

查看:54
本文介绍了模块“pickle"没有属性“dump"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import pickle

imelda = ('More Mayhem',
          'IMelda May',
          '2011',
          ((1, 'Pulling the Rug'),
           (2, 'Psycho'),
           (3, 'Mayhem'),
           (4, 'Kentish Town Waltz')))

with open("imelda.pickle", "wb") as pickle_file:
    pickle.dump(imelda, pickle_file)

我正在尝试执行此代码,但控制台一直告诉我:

I am trying to execute this code, but the console keeps telling me:

module 'pickle' has no attribute 'dump'

我必须通过 pip 安装 pickle 吗?我不确定这里发生了什么.

Do I have to install pickle via pip? I am not sure what is happening here.

推荐答案

我也遇到过.我的当前目录中有一个名为 pickle.py 的文件.只需重命名它即可修复:)

Happened to me too. I had a file called pickle.py in my current directory. Just rename it and it's fixed :)

这篇关于模块“pickle"没有属性“dump"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆