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)