zuier 发表于 2018-6-15 09:08:44

python windows备份文件info-zip

import os  
import time
  
#1.需要备份的文件或者文件夹
  
source = ['d:\\sll','D:\\download']
  
#2.需要备份的存放目录
  
target_dir = 'd:\\pyback\\'
  
#3要压缩的文件
  
target = target_dir + time.strftime('%Y%m%d%H%M%S')+'.zip'
  
print target
  
zip_command = "zip -qr %s %s" % (target,' '.join(source))
  
print zip_command
  
if os.system(zip_command) == 0:
  
print 'Successfull back to',target
  
else:
  
print 'backup failed'
页: [1]
查看完整版本: python windows备份文件info-zip