获取你的
Python
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
import requests #to demonstrate the 'allow_redirects' parameter we use 'http' instead of 'https', w3schools.com automatically redirects http requests to https: url = 'http://w3schools.com/python/demopage.htm' myobj = {'somekey': 'somevalue'} #first, make a request without setting the 'allow_redirects' parameter to False: x = requests.post(url, data = myobj) print(x.text) print("----------------") #then, make a request with the 'allow_redirects' parameter set to False: x = requests.post(url, data = myobj, allow_redirects=False) print(x.text)
<!DOCTYPE html>
<html>
<body>
<h1>这是一个测试页面</h1>
</body>
</html>
----------------
<head><title>文档已移动</title></head>
<body><h1>对象已移动</h1>该文档可以从 <a HREF="https://w3schools.org.cn/python/demopoage.htm">这里</a> 找到</body>