[Py] Python json str 字符串转为对象 (字典)

通过llama.cpp与羊驼聊天的网页界面- 详解 Serge 的启动使用

 

import json

 

json = '{"code": 0}'

 

# Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance containing a JSON document) to a Python object.

obj = json.loads(json)

 

# <class 'dict'>

print(type(obj))

 

print(obj['code'])

 

Cool:在线运行Python代码

Tool:在线 AI 编程助手

Link:https://www.cnblogs.com/farwish/p/13219131.html

posted on 2020-07-01 14:36  ercom  阅读(2939)  评论(0编辑  收藏  举报