pythonの辞書はjsonとしてインストールされています
721 ワード
import json
dic = {
'str': 'this is a string',
'list': [1, 2, 'a', 'b'],
'sub_dic': {
'sub_str': 'this is sub str',
'sub_list': [1, 2, 3]
},
'end': 'end'
}
a = json.dumps(dic)
print a
出力結果:{"sub_dic":{"sub_str":"this is sub str","sub_list":[1,2,3]},"end":"end","end","list":[1,2,"a","b","str":"this is a string"}