Python 官方文档:入门教程 => 点击学习
string =" { "status": "error", "messages": ["Could not find resource or o
}"
print '对象:' string
print '取值:' JSON.loads(string)['code']
输出结果为:
对象:{u'status': u'error', u'code': 404, u'messages': [u"Could not find resource or operation 'BZK1.MapServer' on the system."]}
取值:404
将对象转成字符串:
resultjson = {"state": 1}
print json.dumps(resultJson)
分别使用了Json包中的loads()方法和dumps()方法
--结束END--
本文标题: python中将字符串转为json对象并
本文链接: https://www.lsjlt.com/news/187107.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0