python对json字符串的转换

JSON解析的例子

功能:把json字符串转成python语言的dict

#coding: utf-8
import json

json_str = """
{
    "id" : 90,
    "name" : "python",
    "url" : "http://www.baidu.com",
    "title" : "Python",
    "title_alternative" : "Python",
    "topics" : 7646,
    "stars" : 4862,
        "header" : "Python 语言",
        "footer" : null,
    "created" : 1278683336,
    "avatar_mini" : "//v2ex.assets.uxengine.net/90_mini.png?m=1504",
}
"""
res = json.loads(json_str)

print(res['id']) # 90
print(res['name']) # python
print(res['url']) # http://www.baidu.com
posted @ 2019-08-01 17:47  fengyanhuaivy  阅读(180)  评论(0编辑  收藏  举报