• 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中super的用法实例
  • 九步学会Python装饰器
  • Python实现的监测服务器硬盘使用率脚本分享
  • python进阶教程之模块(module)介绍
  • python生成式的send()方法(详解)
  • python中zip和unzip数据的方法
  • Python实现TCP协议下的端口映射功能的脚本程序示例
  • 用Python编写一个基于终端的实现翻译的脚本
  • Python中的map()函数和reduce()函数的用法
  • python爬虫入门教程之点点美女图片爬虫代码分享

文章分类

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

最近更新的内容

    • Python文档生成工具pydoc使用介绍
    • 优化Python代码使其加快作用域内的查找
    • Python中replace方法实例分析
    • 在Python中处理列表之reverse()方法的使用教程
    • Windows系统下使用flup搭建Nginx和Python环境的方法
    • Python中用Descriptor实现类级属性(Property)详解
    • Python的time模块中的常用方法整理
    • 使用Python将数组的元素导出到变量中(unpacking)
    • 在Ubuntu系统下安装使用Python的GUI工具wxPython
    • Windows下python2.7.8安装图文教程

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

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