AttributeError: 'module' object has no attribute 'request'

前端 未结 4 1644
灰色年华
灰色年华 2021-01-30 02:02

When I run the following code in Python 3.3:

import urllib
tempfile = urllib.request.urlopen(\"http://yahoo.com\")

I get the following error:

4条回答
  •  执念已碎
    2021-01-30 02:49

    Interestingly, I noticed some IDE-depending behavior.

    Both Spyder and PyCharm use the same interpreter on my machine : in PyCharm I need to do

    import urllib.request

    while in Spyder,

    import urllib

    does fine

提交回复
热议问题