Traditional Culture Encyclopedia - Weather forecast - Python json quick parsing command
Python json quick parsing command
Json.dumps is used to encode Python objects into Json strings.
Json.loads is used to decode Json data. This function returns the data type of Python field.
The demjson.encode () function is used to encode Python objects into json strings.
The function decodes json data. This function returns the data type of Python field.
1. The following example encodes an array as data in JSON format:
#! /usr/bin/python
Import json
data = [ { 'a' : 1,' b' : 2,' c' : 3,' d' : 4,' e' : 5 } ]
json = json.dumps(data)
Print json
2. The following example shows how Python decodes JSON objects:
#! /usr/bin/python
Import json
jsonData = '{"a": 1," b":2," c":3," d":4," e ":5 } ';
text = json.loads(jsonData)
Print text
- Related articles
- Top Ten Cities in China
- What was the weather like in Ningbo on February 4th 1992?
- What are the customs in early autumn?
- Do you fish crucian carp after National Day every year?
- The weather forecast of Xuzhou in the coming week
- What impact will the smog in Beijing have on people's lives?
- What is the annual temperature in Weihai? What is the coldest temperature in winter?
- Why is it so hot in Wuhan?
- The weather today and tomorrow
- Can the grain depot be yellow