#list转成Json格式数据
deflistToJson(lst):
importjson
importnumpyasnp
keys=[str(x)forxinnp.arange(len(lst))]
list_json=dict(zip(keys,lst))
str_json=json.dumps(list_json,indent=2,ensure_ascii=False)#json转为string
returnstr_json
结果
{
“0”:”123″,
“2”:”34″,
“3”:”456″,
“1”:”345″
}