日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
python教程在例10.4備份腳本的代碼的介紹

python教程在例10.4 備份腳本——版本四的代碼是相當(dāng)長的,所以很多人對其有束手無策之感,但是你通過以下的代碼對其,有更好的了解,以下就是相關(guān)內(nèi)容的詳細(xì)介紹。希望你會有所收獲。

企業(yè)建站必須是能夠以充分展現(xiàn)企業(yè)形象為主要目的,是企業(yè)文化與產(chǎn)品對外擴(kuò)展宣傳的重要窗口,一個合格的網(wǎng)站不僅僅能為公司帶來巨大的互聯(lián)網(wǎng)上的收集和信息發(fā)布平臺,創(chuàng)新互聯(lián)面向各種領(lǐng)域:成都VR全景成都網(wǎng)站設(shè)計(jì)成都全網(wǎng)營銷解決方案、網(wǎng)站設(shè)計(jì)等建站排名服務(wù)。


 
 
 
  1. #!/usr/bin/python
  2. # Filename: backup_ver4.py
  3. import os
  4. import time
  5. # 1. The files and directories to be backed up are 
    specified in a list.
  6. source = [‘/home/swaroop/byte’, ‘/home/swaroop/bin’]
  7. # If you are using Windows, use source =
     [r'C:\Documents'
    , r'D:\Work'] or something like that
  8. # 2. The backup must be stored in a main backup
     directory
  9. target_dir = ‘/mnt/e/backup/’ # Remember to change 
    this to what you will be using
  10. # 3. The files are backed up into a zip file.
  11. # 4. The current day is the name of the 
    subdirectory in the main directory
  12. today = target_dir + time.strftime(‘%Y%m%d’)
  13. # The current time is the name of the zip archive
  14. now = time.strftime(‘%H%M%S’)
  15. # Take a comment from the user to create the name 
    of the zip file
  16. comment = raw_input(‘Enter a comment –> ‘)
  17. if len(comment) == 0: # check if a comment was entered
  18. target = today + os.sep + now + ‘.zip’
  19. else:
  20. target = today + os.sep + now + ‘_’ + \
  21. comment.replace(‘ ‘, ‘_’) + ‘.zip’
  22. # Notice the backslash!
  23. # Create the subdirectory if it isn’t already there
  24. if not os.path.exists(today):
  25. os.mkdir(today) # make directory
  26. print ‘Successfully created directory’, today
  27. # 5. We use the zip command (in Unix/Linux) to put the 
    files in a zip archive
  28. zip_command = "zip -qr ‘%s’ %s" % (target, ‘ 
    ‘.join(source))
  29. # Run the backup
  30. if os.system(zip_command) == 0:
  31. print ‘Successful backup to’, target
  32. else:
  33. print ‘Backup FAILED’

文中提到“我還希望有的一個優(yōu)化是使用tar命令替代zip命令。這樣做的一個優(yōu)勢是在你結(jié)合使用tar和gzip命令的時候,備份會更快更小。如果你想要在Windows中使用這些歸檔,WinZip也能方便地處理這些.tar.gz文件。tar命令在大多數(shù)Linux/Unix系統(tǒng)中都是默認(rèn)可用的。Windows用戶也可以下載安裝它。命令字符串現(xiàn)在將成為:

 
 
 
  1. tar = ‘tar -cvzf %s %s -X /home/swaroop/
    excludes.txt’ % (target, ‘ ‘.join(srcdir))

需要補(bǔ)充的是Windows用戶安裝完LibArchive后命令為bsdtar,而且若想使用-z這個選項(xiàng),還需安裝gzip軟件。代碼中的

 
 
 
  1. target = today + os.sep + now + ‘.zip’

改為

 
 
 
  1. target = today + os.sep + now + ‘.tar.gz’

使用

 
 
 
  1. bsdtar -cvzf %s %s -X /home/swaroop/
    excludes.txt’ % (target, ‘ ‘.join(source))

以上的內(nèi)容就是對簡明python教程在例10.4 備份腳本——版本四的代碼中有些需要注意的地方的詳細(xì)介紹。


名稱欄目:python教程在例10.4備份腳本的代碼的介紹
瀏覽路徑:http://m.5511xx.com/article/dhsedig.html