Pickle库使用练习报错 AttributeError: module 'pickle' has no attribute 'dump'
在这里插入代码片在练习使用pickle模块的时候写了如下的代码,但是出现了报错,代码和报错内容如下:
代码:
import pickle
dict1 = dict(name='八岐大蛇', age=100, sex='男', addr='东方', enemy=['八神', '草薙京', '神乐千鹤'])
print(dict)
file1 = open('d:\\py-pickle.txt', 'w')
pickle.dump(dict1, file1, 1)
file1.close()
报错:
E:\Py_Tortoise\venv\Scripts\python.exe E:/Py_Tortoise/pickle.py
<class 'dict'>
Traceback (most recent call last):File "E:/Py_Tortoise/pickle.py", line 1, in <module>import pickleFile "E:\Py_Tortoise\pickle.py", line 6, in <module>pickle.dump(dict1, file1, 1)
AttributeError: module 'pickle' has no attribute 'dump'Process finished with exit code 1
这个报错是说pickle这个模块没有dump属性,
最终发现的文件名pickle.py和标准库pickle命名冲突了,需要修改掉自己写的文件名
Pickle库使用练习报错 AttributeError: module 'pickle' has no attribute 'dump'相关推荐
- python 报错 AttributeError: module ‘time‘ has no attribute ‘clock 解决方法
源码如下: #引入所需要的时间库 import datetime import time#程序计时器,启动计时器 start = time.clock()#中间是放置需要测试运行时间的程序代码#计算启 ...
- pyinstall :打包 .exe 文件报错AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘
有疑问的地方 参考博文 一.环境搭建 Python GUI图形化小工具编程学习-- PySide2 环境搭建(一) 二.实例演示 Python GUI图形化小工具编程学习-- Demo 实例演示(二) ...
- 第一:Python+Allure运行报错AttributeError: module ‘allure‘ has no attribute ‘severity_level‘
1.很多查询结果都是先卸载pytest-allure-adaptor,然后再安装allure-pytest pip3 uninstall pytest-allure-adaptor 2.pip3 in ...
- python中引入包的时候报错AttributeError: module ‘sys‘ has no attribute ‘setdefaultencoding‘解决方法?
python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法? 参考文章: (1)pyth ...
- 学习python-mysql:报错AttributeError: module 'MySQLdb' has no attribute 'cursors'
爬虫写入数据库时报错: AttributeError: module 'MySQLdb' has no attribute 'cursors' 解决方法: 引入 import MySQLdb.curs ...
- NVIDIA Jetson Xavier NX上导入tensorflow报错:AttributeError: module ‘wrapt‘ has no attribute ‘ObjectProxy‘
欢迎大家关注笔者,你的关注是我持续更博的最大动力 原创文章,转载告知,盗版必究 在Jetson Xavier NX上导入tensorflow报错:AttributeError: module 'wra ...
- python安装dlib(已成功并且无出现报错AttributeError: module ‘dlib‘ has no attribute ‘get_frontal_face_detecetor
众所周知,安装库的方法有很多种 尝试1.直接进行pip安装 pip install dlib -i https://mirrors.ustc.edu.cn/pypi/web/simple(此处在pyt ...
- 解决ray报错AttributeError: module ‘aioredis‘ has no attribute ‘create_redis_pool‘
解决方法 将aioredis版本倒退到1.3.1,1.3.0或以下版本 pip install aioredis==1.3.1 问题解析 aioredis是用来连redis的工具,但在aioredis ...
- 【Flask】flask-bootstrap报错AttributeError: module ‘dominate.tags‘ has no attribute ‘input‘解决方法
问题 在使用flask-bootstrap渲染表单时,报错AttributeError: module 'dominate.tags' has no attribute 'input'. 解决方法 修 ...
最新文章
- WPF解析TTF 字体
- 深度学习 英文 训练阶段_半监督深度学习训练和实现小Tricks
- RxSwift UI控件扩展
- 上下布局:上部分高度自己撑起,下部分高度占满剩下的全部
- Matlab错误:Y must be a vector or a character array
- HDU 5527:Too Rich(DFS+贪心)***
- python统计字典里面value出现的次数_python统计字典中元素出现的次数
- java自定义方法参数注解_Java方法中的参数太多,第1部分:自定义类型
- slide简介(大数据技术)
- docker搭建ldap
- unix网络编程之简介和运输层TCP/UDP
- 柳传志:如何看人和用人
- ORBSLAM3整体框架
- oos的上传和下载2
- php网站整合ck播放器,网页视频播放器-ckplayer 整合到wordpress
- Jenkins 打包配置
- 西门子数控机床如何用FTP进行程序传输
- 打工人最怕听到的词是团建
- 用ffmpeg将视频转成gif动图
- Linux驱动开发-编写RFID-RC522射频刷卡模块驱动
热门文章
- 【Unity入门计划】制作RubyAdventure03-使用碰撞体触发器实现世界交互
- 支付宝开放平台C++方式接入
- Scrapy爬取盗墓笔记 0.2版(mongedb redis)
- itext导出pdf中新加一页空白页面(itext 遇到的问题持续更新)
- 十句职场不败的经典名言
- JS 缩放指定的html元素
- SpringBoot国际化配置(i8n配置)未生效(完美解决)
- 计算机专业函授,计算机专业函授自我鉴定
- DSPE-PEG2K-DOTA二硬脂酰基磷脂酰乙醇胺- 聚乙二醇-四氮杂环配体PEG分子量可以选择1000、2000、3400和5000等等
- Spring Boot 全局异常处理(400/404/500),顺便解决过滤器中异常未捕获到的问题,让RestApi 任何时候都能获取统一的格式代码