Python built-in module (shelve)--035

Source: Internet
Author: User

I. Introduction of SHELVE

1, shelve is a simple data storage scheme, he has only one function is open (), the function receives a parameter is the file name, and then return a shelf object, you can use him to store things, you can simply think of him as a dictionary, when you are stored, Just call the close function to close the

2, shelve module is a simple k,v memory data through the file persistence module, you can persist any pickle can support the Python data format

Second, examples

Import shelve,datetimed = Shelve.open (' E:\python-project\\f7 ')  # Open a file print (D.get (' name ')) print (D.get (' info ') Print (D.get (' Date ')) info = {' age ': ' + ', ' job ': ' it '}name = ["Alex", "Rain", "Test"]d["name"] = name  # persistent list d["info"] = Info  # persistence class d["date"] = Datetime.datetime.now () d.close ()

  

Python built-in module (shelve)--035

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.