newbie urlopen() question
Olivier Dagenais
olivierS.dagenaisP at canadaA.comM
Tue Jul 18 21:26:19 EDT 2000
Well, your URL is malformed. For local files, it usually has to be prefixed
with "file://", so try
url = "file://a:/1.htm"
--
----------------------------------------------------------------------
Olivier A. Dagenais - Carleton University - Computer Science III
<c825934 at vitgcab4.telstra.com.au> wrote in message
news:8l2lts$fln$1 at nnrp1.deja.com...
> I have a simple file on my A drive (in the root) called 1.htm.
>
> Why doesn't the following code succeed in opening the file? (It works
> fine if I assign a valid http address to url. But when I assign the
> address below the IOError occurs):
>
> import urllib
> url="a:1.htm"
>
> try:
> f = urllib.urlopen(url)
> print f.read()
> except IOError:
> print "Could not open " + url
>
> Any help much appreciated.
>
> Peter Dann
> Melbourne, Australia
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
More information about the Python-list
mailing list