我是Python的新手,并且让他跟随错误。但是,当我在邮递员中运行同一件作品时,它运行良好。实际上,以下代码取自Postman的代码选项本身,而我刚刚从标题中删除了postman令牌。我在做错什么吗?
File "addusers.py", line 20, in addusers
response = requests.get(url, headers=headers, verify=False)
File "/usr/lib/python2.6/site-packages/requests/api.py", line 68, in get
return request('get', url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 464, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 415, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='something.com', port=443): Max retries exceeded with url: /pod/test/i0HkG6dA/list (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x2464450>, 'Connection to something.com timed out. (connect timeout=50)'))
我的代码如下:
import requests
url = "https://something.com/pod/test/iFoFA6dA/list"
headers = {
'sessionToken': "1ae9234fb9c7a4901992",
'Cache-Control': "no-cache",
# 'Postman-Token': "d1cf7cf5-9b56-42bf-be39-4e534f41325f"
}
print("hi")
response = requests.request("GET", url, headers=headers)
print("bye")
print(response.text)