urllib.error.URLError:

后端 未结 4 1351
-上瘾入骨i
-上瘾入骨i 2020-11-29 12:09

(Python 3.4.2) I\'ve got a weird error when I run \'urllib.request.urlopen(url)\' inside of a script. If I run it directly in the Python interpreter, it works fine, but not

4条回答
  •  星月不相逢
    2020-11-29 12:54

    You should use urllib.parse.urlencode(), urllib.parse.urljoin(), etc functions to construct urls instead of manually joining the strings. It would take care of : -> %3A conversion e.g.:

    >>> import urllib.parse
    >>> urllib.parse.quote(':')
    '%3A'
    

提交回复
热议问题