def close(self):
if self.directory_real:
# print(self.directory, self.directory_real)
with zipfile.ZipFile(self.directory_real, "w") as z:
for root, dirs, files in os.walk(self.directory.replace("\\", "/"), topdown=True):
new_root = root.replace("\\", "/").split("/")
# print(root, dirs, files)
for name in files:
z.write(os.path.join(root, name), "/".join(new_root[new_root.index(
self.directory.replace("\\", "/").split("/")[-1]) + 1:]) + "/" + name)
self.d.cleanup()
self.destroy()
评论列表
文章目录