[Python]attributeerror: ' Module ' object has no attribute ' dump '

Source: Internet
Author: User
Problem


"Code" file name: pickle.py

# coding=utf-8# Persistent Storage Import pickle#b open file in binary mode with open (' Mydata.pickle ', ' WB ') as Mysavedata:   #用dump保存数据   Pickle.dump ([Up, ' three '],mysavedata) #b open the file in binary mode with open (' Mydata.pickle ', ' RB ') as Myreaddata:   #使用load恢复数据   list = pickle.load (myreaddata) Print List

Solution

The main problem is that it originates from this file name pickle.py

Because this file name conflicts with the module name in the Python standard library. So you import pickle instead of importing the modules in the standard library and importing the files you created yourself.

Just re-change the file name and it's OK.




[Python]attributeerror: ' Module ' object has no attribute ' dump '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.