It says to use import urllib2 but I get this error: Traceback (most recent call last): File "D:\MyDocs\Python\Element Tree for XML\weather.py", line 2, in <module> import urllib2 ImportError: No module named urllib2
On Thu, Dec 22, 2011 at 11:41 AM, Hugo Arts <hugo.yo...@gmail.com> wrote: > On Thu, Dec 22, 2011 at 5:33 PM, Cranky Frankie > <cranky.fran...@gmail.com> wrote: >> On the bottom of this web page: >> >> http://developer.yahoo.com/python/python-xml.html >> >> is a program that reads an RSS feed for the weather and then parses >> the XML to show weather data by a zip code you input. I'm trying to >> run this under Python 3.2 and get this error: >> >> Traceback (most recent call last): >> File "D:\MyDocs\Python\Element Tree for XML\weather.py", line 27, in >> <module> >> pprint(weather_for_zip(12303)) >> File "D:\MyDocs\Python\Element Tree for XML\weather.py", line 10, in >> weather_for_zip >> dom = minidom.parse(urllib.urlopen(url)) >> AttributeError: 'module' object has no attribute 'urlopen' >> >> I'm wondering if this is because this is Python 2.x code? Can someone >> who has 2.x try to run this and let me know if that's the problem? Is >> there a way to get this to work in Python 3.2? >> > > I usually find it helpful to check the documentation before doing > anything else when I encounter errors like this in code found online. > Right here: > > http://docs.python.org/library/urllib.html > > At the top of the page you should find the information you need > (you're right on the money, basically). > > HTH, > Hugo -- Frank L. "Cranky Frankie" Palmeri _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor