Python and urllib

前端 未结 3 1068
感动是毒
感动是毒 2020-12-19 07:12

I\'m trying to download a zip file (\"tl_2008_01001_edges.zip\") from an ftp census site using urllib. What form is the zip file in when I get it and how do I save it?

3条回答
  •  太阳男子
    2020-12-19 07:53

    Per the docs, urlretrieve puts the file to disk and returns a tuple (filename, headers). So the file is already saved when urlretrieve returns.

    You can open and read the ZIP file you've retrieved with the zipfile module of the standard library. glob does not work inside zipfiles, only on normal filesystem directories.

提交回复
热议问题