Zip文件在python中保存错误

时间:2017-03-03 04:04:55

标签: python zipfile

不是将由C:/ Users / User / Desktop / Folder制作的zip文件保存为ZipFile.zip/Folder,而是将zip文件保存为ZipFile.zip/Users/User/Desktop/Folder

下面使用的Python变量:

以下代码:

backUp = raw_input("> ")
backDevice = raw_input("> ")
backZip = raw_input("> ")
dest = backDevice + "/BackUp"

bkZip = zipfile.ZipFile(os.path.join(dest, backZip), 'w')
for dirname, subdirs, files in os.walk(backUp):
    bkZip.write(dirname)
    for filename in files:
        bkZip.write(os.path.join(dirname, filename))
bkZip.close()

0 个答案:

没有答案