- json.dumps 將 Python 對(duì)象編碼成 JSON 字符串
- json.loads 將已編碼的 JSON 字符串解碼為 Python 對(duì)象
- 還有更多高級(jí)的用法:http://www.runoob.com/python/python-json.html
>>> foo={"a":1,"b":2}
>>> type(foo)
<type 'dict'>
>>> foo
{'a': 1, 'b': 2}
>>> import json
>>> bar=json.dumps(foo)
>>> type(bar)
<type 'str'>
>>> bar
'{"a": 1, "b": 2}'
>>> foo=json.loads(bar)
>>> type(foo)
<type 'dict'>
>>> foo
{u'a': 1, u'b': 2}