Module--json

Source: Internet
Author: User

Outline

①json, what's the use?

② Method Introduction and Small example

JSON is a cross-platform, cross-language interaction, used to convert each other.

Ii. Introduction of methods

1json.loads (str) converts the string form of dict, list, tuple to notional.

Note: Because only other languages double quotes are not representative strings, we use single quotes for our arguments.

Out of the Py language, other languages have no (), so the tuple-type string cannot be converted.

Import Jsona = ' [Hello ', 11,22] ' B = json.loads (a) print (b) #[' Hello ', 11, 22]

Json.dumps (a) a represents the Dict, list, and tuple to convert dict, list, tuple to string.

Note: The tuple will be converted to list, other languages do not say.

Import Jsona = ("Hello", 11,22) b = Json.dumps (a) print (b) #["\u4f60\u597d", 11, 22]

Additional knowledge:

Json.load (Open (' xx ', r)) → convert the string in xx file to notional → Open xx file in R mode.

Json.dump (Yy,open (' xx ', W)) → Convert the object yy to a string → Open the xx file in W, and deposit the converted yy in XX.

  

Module--json

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.