欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python在windows下實現(xiàn)備份程序?qū)嵗?/h1>
 更新時間:2014年07月04日 18:16:43   投稿:shichen2014  
這篇文章主要介紹了python在windows下實現(xiàn)備份程序,需要的朋友可以參考下

很多書籍里面講的Python備份都是在linux下的,而在xp上測試一下也可以執(zhí)行備份功能,代碼都差不多相同,就是到執(zhí)行打包的時候是不一樣的。而且要用到winrar,其他的壓縮文件也是一樣的。

首先我們要把winrar的路徑添加到path里面,這里添加完了要重啟機子才有效。
這里要注意:把winrar的路徑添加到path里面之后一定要重啟,否則path的設定不會起作用,打包就會失敗!
 
這里用到得命令是:winrar a xxx.zip xxxx
xxx為任意字符
 
實例代碼如下:

#備份腳本,用來備份的 
#Filename:backup_ver1.py 
import os 
import time 
import sys 
#備份的源文件路徑 
sourc = ['G://test//test.txt'] 
#備份的文件所放的地方 
target_dir = 'G://' 
#備份文件的名字 
target = target_dir + time.strftime('%Y%m%d%H%M%S')+'.rar' 
#zip_command = "zip -qr '%s' %s" % (target,''.join(sourc)) 
#zip_command = "winrar a /"%s/" %s" % (target,' '.join(sourc)) 
zip_command="winrar a %s %s" %(target,' '.join(sourc)) 
print zip_command 
if os.system(zip_command) == 0: 
  print '打包成功!'+target 
else: 
  print '打包失??!

相關文章

最新評論