我是python的新用户。我不知道为什么,但请求总是抛出 InvalidURL 异常:
>>> import requests
>>> r = requests.get('https://www.google.es/')
Run Code Online (Sandbox Code Playgroud)
输出:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/requests/models.py", line 380, in prepare_url
scheme, auth, host, port, path, query, fragment = parse_url(url)
File "/usr/lib/python3/dist-packages/urllib3/util/url.py", line 392, in parse_url
return six.raise_from(LocationParseError(source_url), None)
File "<string>", line 3, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: https://www.google.es/
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/requests/api.py", line 76, in get
return request('get', url, …Run Code Online (Sandbox Code Playgroud)