Python备份程序的字节不适用于Windows系统

时间:2017-02-20 10:59:20

标签: python-2.7

python备份程序的字节无法正常工作

我得到的错误是zip命令在Windows命令提示符下不是可识别的命令,即使在安装了zip实用工具并设置环境变量之后

这是代码:

import os
import time

source = ['"F:\PYTHON\byte of python code"']
target_dir = 'F:\\Backup'
target = target_dir + os.sep + time.strftime('%Y%m%d%H%M%S') + '.zip'
if not os.path.exists(target_dir):
    os.mkdir(target_dir) # make directory
zip_command = "zip -r {0} ".format(target,' '.join(source))
print "Zip command is:"
print zip_command
print "Running:"
if os.system(zip_command) == 0:
    print 'Successful backup to', target
else:
    print 'Backup FAILED'

raw_input("Press<Enter>")

我得到的错误是

Zip command is:
zip -r F:\Backup\20170220120316.zip
Running:
'zip' is not recognized as an internal or external command,
operable program or batch file.
Backup FAILED
Press<Enter>

非常感谢任何帮助。谢谢

0 个答案:

没有答案
相关问题