python dict conver json
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python dict conver json相关的知识,希望对你有一定的参考价值。
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]
以上是关于python dict conver json的主要内容,如果未能解决你的问题,请参考以下文章
javascript listas transformar valores dropdown filtro insertaFiltro insertaFiltros convertir convers