乱码展示:
requests请求成功时,设置它的编码,
用.encoding='编码格式 ’ 的方法可解决
编码格式:gzip 打开网页可查看源码是使用的哪种。
附源码:
from urllib.parse import urljoin
import requests
url = 'https://account.cnblogs.com'
get_path = '/signin/'
def test_get():
res = requests.get(urljoin(url, get_path))
res.encoding = 'gzip' #设置编码
return res.text
account = test_get()
print(account)
结果:



