python-json模块扩展

sort_keys=True, indent=4, separators=(',', ': ')  #格式

json.dumps(response,sort_keys=True, indent=4, separators=(',', ': '),ensure_ascii=False)  #ensure_ascii 解析中文





#自定制json class MEncode(json.JSONEncoder): def default(self, o): return int(o) response = json.dumps(response,ensure_ascii=False,cls=MEncode)

 

posted @ 2019-04-12 11:05  SwZ1886  阅读(131)  评论(0编辑  收藏  举报