跟着简明python学习模仿做了一个用HaoZip压缩备份的程序
首先,还是在系统设置中设置好HaoZip的环境变量
# !usr/bin/python
import os
import time
source = r'C:\Users\Administrator\Desktop\backup'
print source
target_dir = r'C:\Users\Administrator\Desktop\backup'
target = target_dir+time.strftime('%Y%m%d')+'.zip'
zip_command = "HaoZipC a -tzip %s %s " % (target,source)
if os.system(zip_command) == 0:
<span style="white-space:pre"> </span>print 'successful'
else:
<span style="white-space:pre"> </span>print 'failed'