On Mon, Oct 25, 2010 at 08:38, Sander Sweers <[email protected]> wrote:
> Have you actually tried reading the documentation?
Of course. Though I can see why you wondered.
>The _very_ first
> section of the urllib documentation we have urllib.request.urlopen
> [1]. Which looks to me what you are looking for as a replacement to
> urllib2.urlopen().
What I tried were these 3 lines:
import urllib
a =
urllib.request.urlopen('http://www.marketwatch.com/investing/currency/CUR_USDYEN').read(20500)
print(a[123:140])
which got me
Traceback (most recent call last):
File "c:\P31Working\test_urllib.py", line 2, in <module>
a =
urllib.request.urlopen('http://www.marketwatch.com/investing/currency/CUR_USDYEN').read(20500)
AttributeError: 'module' object has no attribute 'request'
Process terminated with an exit code of 1
Doing it your way,
from urllib import request
a =
request.urlopen('http://www.marketwatch.com/investing/currency/CUR_USDYEN').read(20500)
print(a[123:140])
succeeds. Why?
Anyway, thanks.
Dick
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor