urlretrieve a file whose name has spaces in it

Skip Montanaro skip at pobox.com
Thu Jul 31 01:04:19 EDT 2003


    Kevin> You can easily escape spaces with "%20" as in:

    Kevin> urllib.urlretrieve("http://website.com/path/string string1
    Kevin> foo.doc".replace(" ", "%20"), "local_file")

Better yet, use url.quote() to make sure all special characters get quoted
in the right way depending on where they are in the URL:

    import urllib
    help(urllib.quote)

Skip





More information about the Python-list mailing list