python网络请求:发送GET请求并获取响应内容
import requests
url = "http://tzshw.com" # 替换为你的URL
response = requests.get(url)
# 假设服务器返回的是UTF-8编码,如果不是,需要替换为正确的编码
content = response.content.decode('utf-8')
print(content)
以下对中文显示为乱码:
import requests
url = 'http://tzshw.com'
response = requests.get(url)
print(response.text)