Opening file with urllib

Jon Cosby jcosby at wolfenet.com
Fri Oct 27 12:36:11 EDT 2000


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





More information about the Python-list mailing list