• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python使用7z解压软件备份文件脚本分享

python使用7z解压软件备份文件脚本分享

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python 7z,手机 7z解压,7z解压,7z解压软件64位apk,7z解压器等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

要求安装:

1.Python
2.7z解压软件

backup_2.py

'''Backup files.
    Version: V2, based on Python 3.3
    Usage: backup.py -s:"dir1|dir2|..." -t:"target_dir" [-c:"comment"]
        -s: The source directories.
        -t: The target directory.
        -c: Optional, any comment.
    Examples:
        backup.py -s:"c:\\src\\F1|c:\\src\\F2|c:\\src\\F 3" -t:"c:\\backup"
        backup.py -s:"c:\\src\\F 3" -t:"c:\\backup" -c:"For sample"'''

import os
import sys
import time

# Read sys.argv
print(sys.argv)
if len(sys.argv) < 2:
    print(__doc__)
    sys.exit()

source=[]
target_dir=''
comment=''
for arg in sys.argv:
    if arg.startswith('-s:'):
        source=arg[3:].split('|')
        print(source)
    elif arg.startswith('-t:'):
        target_dir=arg[3:]+os.sep
        print(target_dir)
    elif arg.startswith('-c:'):
        comment=arg[3:]
        print(comment)

for i in range(0, len(source)):
    source[i] = "\"" + source[i] + "\""
    print(source[i])

# Make the file name with the time and comment
today=target_dir+time.strftime('%Y%m%d')
now=time.strftime('%H%M%S')

if len(comment)==0: # check if a comment was entered
    target=today+os.sep+now+'.7z'
else:
    target=today+os.sep+now+'_'+\
            comment.replace(' ','_')+'.7z'

# Create the subdirectory by day
if not os.path.exists(today):
    os.mkdir(today) # make directory
    print('Successfully created directory',today)

# zip command
zip_command="7z a %s %s" %(target,' '.join(source))
print(zip_command)

# Run the backup
if os.system(zip_command)==0:
    print('Successful backup to',target)
else:
    print('Backup FAILED')
</div>

</div>

您可能想查找下面的文章:

  • python使用7z解压apk包的方法
  • python使用7z解压软件备份文件脚本分享
  • python使用7z解压软件备份文件脚本分享

相关文章

  • Python re模块介绍
  • Python中logging模块的用法实例
  • 利用 Monkey 命令操作屏幕快速滑动
  • python3实现ftp服务功能(服务端 For Linux)
  • python基础教程之五种数据类型详解
  • Python内置的HTTP协议服务器SimpleHTTPServer使用指南
  • Python 执行字符串表达式函数(eval exec execfile)
  • Python中的字符串替换操作示例
  • Python实现查找系统盘中需要找的字符
  • Python中为什么要用self探讨

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 零基础写python爬虫之神器正则表达式
    • Python实现统计单词出现的个数
    • Python 字符串操作方法大全
    • 简单介绍Python的轻便web框架Bottle
    • python3.5实现socket通讯示例(TCP)
    • python解决网站的反爬虫策略总结
    • Python实现全角半角字符互转的方法
    • Python的Flask站点中集成xhEditor文本编辑器的教程
    • python使用wxPython打开并播放wav文件的方法
    • Python中的filter()函数的用法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有