当前位置 : 主页 > 编程语言 > python >

pyhon中返回的网页为中文乱码

来源:互联网 收集:自由互联 发布时间:2022-06-21
import requests response = requests.post('https://www.suimeng.com/modules/article/search.php?searchkey={}'.format('全球高武')) print('status_code:',response.status_code) if response.status_code == 200: #response.encoding = 'utf-8' print
import requests

response = requests.post('https://www.suimeng.com/modules/article/search.php?searchkey={}'.format('全球高武'))
print('status_code:',response.status_code)
if response.status_code == 200:
#response.encoding = 'utf-8'
print('response.headers:',response.headers)
print(response.encoding)
key = 'Content-Encoding'
# print(response.headers[key])
print("-----------")
# if(key in response.headers and response.headers['Content-Encoding'] == 'br'):
# data = brotli.decompress(response.content)
# data1 = data.decode('gbk')
# print(data1)
# print('response.text:',response.text)
print(response.content.decode('gbk'))

设置编码格式response.content.decode(‘gbk’)


上一篇:python中\u编码
下一篇:没有了
网友评论