json python 基本转换

if __name__ == '__main__':
# 将python对象test转换json对象
test = [{"username":"测试","age":16},(2,3),1]
print type(test)
python_to_json = json.dumps(test,ensure_ascii=False)
print python_to_json
print type(python_to_json)

# 将json对象转换成python对象
json_to_python = json.loads(python_to_json)
print json_to_python
print type(json_to_python)

posted on 2018-02-11 16:50  高渐离1992  阅读(110)  评论(0编辑  收藏  举报

导航