【python基础】Json数据格式

json包

字典,列表转换为Json:json.dumps()

import json
data = [{"name":"张大山","age":11},{"name":"王大锤","age":13},{"name":"赵小虎","age":16}]
json_str = json.dumps(data,ensure_ascii=Fasle)
print(type(json_str))

Json转换为字典,列表:json.loads()

s='[{"name":"张大山","age":11},{"name":"王大锤","age":13},{"name":"赵小虎","age":16}]'
l=json.loads(s)

你可能感兴趣的:(python,json,javascript,开发语言)