1.python tornado.escape.json_encode
json对指定的python对象进行编码
2.python tornado.escape.json_decode
返回指定json字符串的python对象,支持str和bytes输入
import tornado.escape
req = {'44': 344, '23': 5}
print(req, type(req))
req12 = {'44': 344, '23': 5}
req1 = tornado.escape.json_encode(req12)
print(req1, type(req1))
print(tornado.escape.json_decode(req1), type(tornado.escape.json_decode(req1)))
**打印结果:
{‘23’: 5, ‘44’: 344} <class ‘dict’>
{“23”: 5, “44”: 344} <class ‘str’>
{‘23’: 5, ‘44’: 344} <class ‘dict’>
**