pickle模块 no attribute 'dumps'
Posted linga
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pickle模块 no attribute 'dumps'相关的知识,希望对你有一定的参考价值。
今天写了一个pickle.py的文件练习pickle模块,代码如下:
import pickle dic = {"linga": (‘football‘,)} dic2 = {"saya": (‘game‘)} dic3 = {"viper": (‘play‘)} with open("pickles.pickle", ‘wb‘) as handle: pickle.dump(dic, handle) pickle.dump(dic2, handle) pickle.dump(dic3, handle) pickle.dump(dic, handle) pickle.dump(dic2, handle)
然后执行代码后就这个样子:
C:Python36python.exe D:/linga/Documents/Python/Module/pickle.py Traceback (most recent call last): File "D:/linga/Documents/Python/Module/pickle.py", line 49, in <module> import pickle File "D:lingaDocumentsPythonModulepickle.py", line 53, in <module> print(pickle.dump(dic)) AttributeError: module ‘pickle‘ has no attribute ‘dump‘ Process finished with exit code 1
这个报错是说pickle这个模块没有dump属性,这个报错的原因是应为自己练习的pickle的文件名pickle.py和标准库pickle命名冲突了,需要修改掉自己写的文件名
2018-07-05 20:48:24
以上是关于pickle模块 no attribute 'dumps'的主要内容,如果未能解决你的问题,请参考以下文章
针对AttributeError: ‘module’ object has no attribute’xxx’的错误归类
python 中json has no attribute 'loads'
unittest模块在linux报错: AttributeError: module 'unittest' has no attribute 'TestRunner'(
AttributeError: type object '_io.StringIO' has no attribute 'StringIO'
解决python中selen模块中'list' object has no attribute 'send_keys'报错