Module explanation----The difference between JSON and pickle modules

Source: Internet
Author: User

1, in the production, dumps and loads only once, and to use W to the original data washed away, so as to ensure that each time is the latest. 2, the snapshot of the virtual machine is that each snapshot has a file, not all are not put together. 3. If you want to produce several serialization, generate multiple files. 4, JSON and pickle have the same method: JSON: for (different platform and multi-language) strings and Python data types for conversion pickle: For Python-specific types and Python data types between the conversion (all Python data types) JSON: module provides four functions: dumps dump loads load pickle: module provides four functions: Dumps dump loads load (1), modify in memory, read by write and read, for loop Write to file: dumps:F.write (Jsoin|pickle.dumps (info))Loadsjson| pickle.loads (F.read ())
(2), directly write files, no other method: dump:json|pickle.dump (info,f)Loaddata = Json|pickle.load (f)Note: Python2 can dump multiple times, load multiple times, 2 times are one by one corresponding Python3 can only dump multiple times, loads, load once

Module explanation----The difference between JSON and pickle modules

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.