1. 程式人生 > >解決python介面測試返回json亂碼問題,解決如下:

解決python介面測試返回json亂碼問題,解決如下:

req = requests.post(url="http://192.168.229.128:8080/cms/manage/loginJump.do",
                            data={"userAccount": "admin", "loginPwd": "123456"})
 results = req.json()
 print(json.dumps(results, sort_keys=True, indent=2, separators=(',', ': '), encoding="UTF-8", ensure_ascii=False))   
 # indent 是間隔長度encoding解決編碼輸出,ensure_asccii解決編碼遮蔽