I have a path to a zip file. I don'开发者_StackOverflow社区t know how to
- retrieve the file from the hard drive or
- open that zip file. Does anyone know?
The zip file is a zip file, but it's really a .epub file.
http://docs.python.org/library/zipfile.html
>>> import zipfile
>>> path = "example/path.epub"
>>> epub = zipfile.ZipFile(open(path))
>>> epub.namelist()
['some_file.txt']
>>> file = epub.open('some_file.txt')
>>> file.read()
You don't need anything Django specific, just use the Python standard library, with the class ZipFile(file_name[, mode[, compression[, allowZip64]]])
from the zipfile
package.
精彩评论