python 壓縮備份文件

跟着簡明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'


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章