Python - 将文件夹及其内容写入 ZipFile
是否可以将文件夹及其内容写入现有的 ZipFile? 我已经搞砸了一段时间了,只能设法将文件夹结构写入存档,文件夹内的任何内容都不会被复制。 我不想指向特定文件,因为这个想法是文件夹内容可以更改,并且程序只会将整个文件夹复制到存档中,无论里面有什么。
目前我有,
myzipfile.write('A Folder\\Another Folder\\')
但我希望复制“另一个文件夹”的内容,而不仅仅是空文件夹
希望您明白我的意思。
Is it possible to write a folder and its contents to an existing ZipFile?
I've been messing around with this for a while and can only manage to write the folder structure to the archive, anything inside the folder isn't copied.
I don't want to point to a specific file, because the idea is that the folder contents can change and the program will just copy the whole folder into the archive no matter what is inside.
Currently I have,
myzipfile.write('A Folder\\Another Folder\\')
but I want the contents of 'Another Folder' to be copied as well not just the empty folder
Hopefully you understand what I mean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
os.walk
:Use
os.walk
: