【非原创】python3 request请求,解析返回字符为汉字

import  requests
import json
 
url = 'http://192.168.1.68:5000/customer/login'
headers = {'Content-Type':'application/json;charset=UTF-8'}
data = {
    'cellphone':'13000000051',
    'password':'e2448e7d027504ef85d254d0798810fe'
}
resonse = requests.post(url=url, data=json.dumps(data),headers= headers)
s =resonse.text.encode('utf-8').decode('unicode_escape')
 
 
print(s)
  1. request简单示例;
  2. 返回字符解析为汉字(python3以上取消了decode,所以你str.decode(“utf-8”)的话会报str没有decode方法的错)
posted @ 2018-11-29 10:58  paulwang2018  阅读(351)  评论(0编辑  收藏  举报