#!/usr/bin/Python
# Filename: backup_ver1.py
import os
import time
source =[r'D:\shi1', r'D:\shi2']
target_dir = 'F:\\back\\'
# 文件夹路径用“\\”表示,这个winrar来决定的
#中文注释和英文注释不同吗
#you will be using
target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.zip'
zip_command= '"C:\Program Files\WinRAR\WinRAR.exe" a %s %s'%(target,' '.join(source))
# Run the backup
if os.system(zip_command) == 0:
print 'Successful backup to', target
else:
print os.system(zip_command)
print 'Backup FAILED'
转载于:https://my.oschina.net/u/2028/blog/484819