I am loading a json file from an API and the data contain Chinese characters, when I just print the result, the characters are perfectly decdoded.
token = "xxxxxxx"
headers = {"Authorization": "Bearer " + token}
apiurl = "https://api.wmcloud.com/data/v1//api/market/getMktBlockd.json?"
param = {
"beginDate": "",
"endDate": "",
"secID": "",
"ticker": "",
"assetClass": "",
"tradeDate": "20190308",
}
r = requests.get(apiurl, params=param, headers=headers)
dataresult = json.loads(r.text)
print(dataresult)
but if I want to print with this function, the characters are again encoded.
print(json.dumps(dataresult, indent=2))
Output is like
"buyerBD": "\u534e\u6cf0\u8bc1\u5238\u80a1\u4efd\u6709\u9650\u516c\u53f8\u6dee\u5b89\u5206\u516c\u53f8",
I have this command at the beginning of my code:
# -*- coding: utf-8 -*-
Why does two functions output different results, how to resolve?
Many thanks.