How do I set permissions (attributes) on a file in a ZIP file using Python's zipfile module?

前端 未结 7 2117
甜味超标
甜味超标 2020-11-30 06:20

When I extract files from a ZIP file created with the Python zipfile module, all the files are not writable, read only etc.

The file is being created and extracted u

7条回答
  •  萌比男神i
    2020-11-30 06:53

    Look at this: Set permissions on a compressed file in python

    I'm not entirely sure if that's what you want, but it seems to be.

    The key line appears to be:

    zi.external_attr = 0777 << 16L
    

    It looks like it sets the permissions to 0777 there.

提交回复
热议问题