Opening file with urllib
Bjorn Pettersen
bjorn at roguewave.com
Fri Oct 27 13:19:53 EDT 2000
It would help alot if you sent the traceback that you're seeing and the
code that it is referring to (with an indication of where the offending
line number is...)
There are no unterminated string constants in your code below, so
something else must be wrong...
-- bjorn
Jon Cosby wrote:
>
> I'm writing a simple CGI script using urllib to open a file. When I run the
> script, I'm getting an error message "Unterminated string constant." The
> problem seems to be in the urlopen() method; when I use the open() method in
> the local path, the script runs as expected. The suspect code is as follows:
>
> def GetLink():
> InFile = urllib.urlopen("http://computer/cgi-bin/Links.txt")
> List = InFile.readlines()
> Link = whrandom.choice(List)
> InFile.close()
> return Link[:-1]
>
> I see that the data arguments aren't required, but what else could it be?
> I'm stumped. If ayone sees what I'm missing, please contact me at
>
> jcosby at wolfenet.com
>
> Jon Cosby
>
> --
> http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list