0
我正在使用Python和請求模塊。但每當我使用「requests.get」有一個網址,我得到的錯誤:Python請求:NewConnectionError
Traceback (most recent call last):
File "python", line 15, in <module>
requests.exceptions.ConnectionError: HTTPSConnectionPool
(host='www.google.com', port=443): Max retries exceeded with url: /?
safe=active&gws_rd=ssl&safe=active (Caused by NewConnectionError
('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at
0x7f86809a16a0>: Failed to establish a new connection: [Errno -2] Name or
service not known',))
這裏是我的代碼:
try:
import requests
except ImportError:
print ("Error: MOD.01")
r = requests.session()
url = "https://www.google.com/?safe=active&gws_rd=ssl&safe=active"
r2 = requests.get(url)
它說的是我的代碼所引發的錯誤? 謝謝。