1.使用requests模块:

import requests

2.通过网络请求,并获取到数据

url = "http://www.stat-nba.com/award/item14.html"
response = requests.get(url)

3.通过获取到的请求结果,调用encoding方法即可得到文本的编码格式

print(response)
print(response.encoding)

输出结果:

<Response [200]>
ISO-8859-1

4.如果要将现在显示的编码改变成utf-8格式,通过如下操作:

response.text.encode("ISO-8859-1").decode("utf-8")

 

相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-01-09
  • 2021-12-09
  • 2022-02-09
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-05-22
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案