这似乎可行(感谢Evan,将其放在此处以使该行符合上下文):
buffer = "path/filename.zip" # zip filename to write (or file-like object)name = "folder/data.txt" # name of file inside zip bytes = "blah blah blah" # contents of file inside zipzip = zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED)info = zipfile.ZipInfo(name)info.external_attr = 0777 << 16L # give full access to included filezip.writestr(info, bytes)zip.close()
我仍然希望看到一些记录此内容的信息…我发现的另一个资源是有关Zip文件格式的注释:http
:
//www.pkware.com/documents/casestudies/APPNOTE.TXT



