import requests # 第三方请求库
url = "http://www.baidu.com"
# 请求头
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) ' }
# 请求-响应
response = requests.get(url,headers=headers)
# print(response.text) # 获取str文本
# print(response.content) # 获取字节,二进制
# print(response.content.decode("utf-8")) # 手动进行解码 str
# print(response.url) # 获取url地址
# response.encoding = "utf-8" #解决乱码
# response.encoding = response.apparent_encoding # 解决乱码
requests-解决乱码问题
最新推荐文章于 2023-12-02 10:45:00 发布