English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Simple implementation method of json format data output in python

Mainly uses the json module, you can directly import import json.

Small example as follows:

#coding=UTF-8 
import json 
info={} 
info["code"]=1 
info["id"]=1900 
info["name"]='张三' 
info["sex"]='男' 
list=[info,info,info] 
data={} 
data["code"]=1 
data["id"]=1900 
data["sex"]='男' 
data["info"]=info 
data["data"]=list 
jsonStr = json.dumps(data) 
print "jsonStr:",jsonStr 
key code: jsonStr = json.dumps(data) 
<span style="font 
family:Arial;BACKGROUND-COLOR: #ffffff">Execution output as follows:<-span>/jsonStr: {"info": {"code": 
" 1, "sex": "\u7537" 1900, "name": "\u5f20\u4e09"} 1, "name": "\u5f20\u4e09"7537" 1, "sex": "\u7537" 1900, "name": "\u5f20\u4e09"} 1, "sex": "\u7537" 1900, "name": "\u5f20\u4e09"} 1, "sex": "\u7537" 1900, "name": "\u5f20\u4e09"}], "id": 1900} 

This is the full content of the simple implementation method of json format data output in Python brought to you by the editor. I hope everyone will support and cheer for the tutorial~

You May Also Like