windows系統(tǒng)中python使用rar命令壓縮多個(gè)文件夾示例
#!/usr/bin/env python
# Filename: backup_ver1.py
import os
import time
# 1. The files and directories to be backed up are specified in a list.
#source=['/home/swaroop/byte','/home/swaroop/bin']
source=['D:\\FileCopier\\*.*','D:\\jeecms_doc\\*.*']
# If you are using Windows, use source=[r'C:\Documents',r'D:\Work'] or something like that
# 2. The backup must be stored in a main backup directory
#target_dir='/mnt/e/backup/' #Remember to change this to what you will be using
target_dir='E:\\temp\\' #Remember to change this to what you will be using
# 3. The files are backed up into a zip file
# 4. The name of the zip archive is the current date and time
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'
# 5. We use the zip command (in Unix/Linux) to put the files in a zip archive
#zip_command="zip -qr '%s' %s" %(target,' '.join(source))
zip_command="rar a " + target + ' '.join(source)
# Run the backup
if os.system(zip_command)==0:
print 'Successful backup to',target
else:
print 'Backup FAILED'
相關(guān)文章
pycharm實(shí)現(xiàn)設(shè)置自動(dòng)的參數(shù)注釋標(biāo)識(shí)
這篇文章主要介紹了pycharm實(shí)現(xiàn)設(shè)置自動(dòng)的參數(shù)注釋標(biāo)識(shí),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-02-02
Pycharm 設(shè)置默認(rèn)解釋器路徑和編碼格式的操作
這篇文章主要介紹了Pycharm 設(shè)置默認(rèn)解釋器路徑和編碼格式的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-02-02
Python實(shí)現(xiàn)合并兩個(gè)字典的8種方法
Python有多種方法可以通過(guò)使用各種函數(shù)和構(gòu)造函數(shù)來(lái)合并字典,本文主要介紹了Python實(shí)現(xiàn)合并兩個(gè)字典的8種方法,具有一定的參考價(jià)值,感興趣的可以了解一下2024-07-07
Python實(shí)現(xiàn)將Excel內(nèi)容插入到Word模版中
前段時(shí)間因?yàn)樾枰幚硪淮蠖羊?yàn)收單,都是一些簡(jiǎn)單的復(fù)制粘貼替換工作,于是就想到用python進(jìn)行處理。本文分享了用python將excel文件單元格內(nèi)容插入到word模版中并保存為新文件的辦法,希望對(duì)大家有所幫助2023-03-03
python?面向?qū)ο箝_(kāi)發(fā)及基本特征
面向?qū)ο缶幊淌且环N編程方式,此編程方式的落地需要使用“類(lèi)”和 “對(duì)象”來(lái)實(shí)現(xiàn),所以,面向?qū)ο缶幊唐鋵?shí)就是對(duì) “類(lèi)”和“對(duì)象” 的使用,今天給大家介紹下python?面向?qū)ο箝_(kāi)發(fā)及基本特征,感興趣的朋友一起看看吧2022-03-03
python實(shí)現(xiàn)感知機(jī)模型的示例
這篇文章主要介紹了python實(shí)現(xiàn)感知機(jī)模型的示例,幫助大家更好的理解和學(xué)習(xí)python 機(jī)器學(xué)習(xí)的相關(guān)知識(shí),感興趣的朋友可以了解下2020-09-09
python導(dǎo)入同級(jí)模塊的實(shí)現(xiàn)
這篇文章主要介紹了python導(dǎo)入同級(jí)模塊的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-02-02

