Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Python/Django 向客户端提交一些 JSON。我是否必须解析它,或者我可以像对待任何其他对象一样开始调用它吗?
您可以使用该json模块将 json 字符串转换为 Python 字典:
json
import json json_str = '{"foo": "bar"}' d = json.loads(json_str) # d = {'foo': 'bar'}
或者从 Python 对象到 json 字符串:
import json d = [1, 2, 3, 4] json_str = json.dumps(d) # json_str = "[1, 2, 3, 4]"