python <2> 压缩备份文件

来源:互联网 发布:我知女人心下载 编辑:程序博客网 时间:2024/06/01 01:33

跟着简明python学习模仿做了一个用HaoZip压缩备份的程序

首先,还是在系统设置中设置好HaoZip的环境变量


# !usr/bin/pythonimport osimport timesource = r'C:\Users\Administrator\Desktop\backup'print sourcetarget_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'


0 0
原创粉丝点击