您的位置:首页 > Web前端 > JavaScript

string to json

2016-05-15 15:33 288 查看
>>> import json
>>> s = '{"skey":"val","ikey":10}'
>>> jo = json.loads(s)
>>> jo
{'ikey': 10, 'skey': 'val'}
>>> jo['ikey']
10
>>> jo['skey']
'val'

json.loads介绍:
json.loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize s (a str instance containing a JSON document) to a Python object using this conversion table.
The other arguments have the same meaning as in load(), except encoding which is ignored and deprecated.
If the data being deserialized is not a valid JSON document, a JSONDecodeError will be raised.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  json