Python JSON encoder and decoder

Reading time ~1 minute

解析Json数据

1
2
3
4
5
6
7
8
9
10
11
>>> import json

>>> content='{"status":200,"msg":"OK","result":{"ticket":"-Ju3np4cSoM~2d75c267eb79f281~1455121096~n~~1~McmMbYV2A84tU471","captcha_url":false,"captcha_w":false,"captcha_h":false,"wait_time":0,"valid_until":"2016-02-10 16:33:17"}}'

>>> content_js = json.loads(content)
>>> content_js.get('status')
>>> ticket = content_js.get('result').get('ticket')

# get_dl_link
>>> url = 'https://api.openload.co/1/file/dl?file=%s&ticket=%s' % (file, ticket)

构造Json数据

1
2
3
4
5
6
7
>>> response = {'status': self.status,
                    'msg': self.msg,
                    'cookie': self.cookie,
                    'result': self.result }

>>> print json.dumps(response, sort_keys=True)
{"cookie": "JSESSIONID=PVzdXNMMpBQQTGvbM1Tcf8YBfDdsjxLLM7VQ4T1WQhFcQzv04WFC!263288888; path=/; HttpOnly, BIGipServerweb_pool=1025311498.16671.0000; path=/", "msg": "OK", "result": "011977", "status": 200}

Written with StackEdit.

AZ-204: Practice topic 5

1. inboundOutboundBackend2. C### [Page 25](https://www.examtopics.com/exams/microsoft/az-204/view/25/)25. 26. 27. 28. 29. ### [Page 26](h...… Continue reading

AZ-204: Practice topic 4

Published on February 20, 2022

AZ-204: Practice topic 3

Published on February 07, 2022