时间:2021-05-22
要求安装:
1.Python
2.7z解压软件
backup_2.py
复制代码 代码如下:
# Filename: 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')
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了python使用7z解压apk包的方法。分享给大家供大家参考。具体如下:这段代码通过shell调用7z对apk包进行解压缩defrun_shell
基本上所有的第三方解压缩软件,都支持解压7z格式的压缩包文件。 因此,用户只要在电脑上安装一个解压缩软件,就可以顺利解压7z文件。 推荐大家可以使用WinR
压缩文件7z和zip的区别是: 1、7z一般对应的软件是7zip,zip对应的是winzip。 2、7z压缩比率大些,zip次之。 3、zip格式比较常见
快压是一款国产压缩软件,支持解压KZ、ZIP、7Z、RAR、MOU、ACE、ARJ、BZ2、CAB、GZ、ISO、JAR、LZH、TAR、UUE、Z等格式文件,
1.关于7z首先在这里先介绍一下7z压缩软件,7z是一种主流的压缩格式,它拥有极高的压缩比。在计算机科学中,7z是一种可以使用多种压缩算法进行数据压缩的档案格式