demo:
import json
import requests
import xml.etree.ElementTree as et
def xmlsjondemo():
data={'statuscode':'200','data':'100','age':'11'}
s=json.dumps(data) #dumps:把字典转换为json字符串
print(type(s))
print(type(d))
def deme1():
r=requests.get(r'http://api.douban.com/v2/book/isbn/9787218087351')
d=json.loads(r.text)
s=json.dumps(d)
print(d['msg'])
print(r.text)
print(type(r.text))
print(d)
print(type(d))
deme1()
invalid_request_scheme: http
{"msg":"invalid_request_scheme: http","code":100,"request":"GET /v2/book/isbn/9787218087351"}
<class 'str'>
{'msg': 'invalid_request_scheme: http', 'code': 100, 'request': 'GET /v2/book/isbn/9787218087351'}
<class 'dict'>
[Finished in 4.4s]