这是代码:
# -*- coding: utf-8 -*-
import os
import time
source = ['F:\\Baby']
target_dir = 'F:\\BackUp'
target = target_dir+os.sep+time.strftime('%Y%m%d%H%M%S')+'.zip'
print(target)
zip_command='zip -qr {0} {1}'.format(target,' '.join(source))
print (zip_command)
if os.system(zip_command)==0 :请输入代码
print ('successfull backup to ',target)
else:
print ('failed backup')
这是输出:
C:Python35python.exe C:/Users/Mr.Fortune/PycharmProjects/untitled/1.py
F:BackUp20160512232004.zip
zip -qr F:BackUp20160512232004.zip F:Baby
'zip' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
failed backup
命令提示符下执行zip -qr F:BackUp20160512232004.zip F:Baby命令成功
不知道为什么出错= =
당신의 문장코드를 입력해주세요, 왜 앞에 댓글이 없나요