【非原创】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)
- request简单示例;
- 返回字符解析为汉字(python3以上取消了decode,所以你str.decode(“utf-8”)的话会报str没有decode方法的错)