Pruthvi Raj Pruthvi Raj - 6 months ago 20
Python Question

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

When i run the following code in Python - 3.3:

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


I get the following error:

enter image description here

I did this too to verify:

enter image description here

What am i doing wrong? Thanks in advance!

Answer

Import urllib.request instead of urllib.

import urllib.request
Comments