网站建设资讯

NEWS

网站建设资讯

创新互联Python教程:Python如何调用rar命令

通过os模块的system()方法调用了系统的RAR.exe命令,这个方法会返回一个变量exit_status。

西吉ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

相关推荐:《python教程》

import os
import time
source = [r‘D:\Work\Python\Demo‘, ‘d:\\work\\linux‘]
target_dir = ‘D:\\Work\\backup\\‘
target = target_dir + time.strftime(‘%Y%m%d%H%M%S‘) + ‘.rar‘
zip_command = "rar a %s %s" % (target, ‘ ‘.join(source))
if os.system(zip_command) == 0:
    print ‘Sucessful backup to‘, target
else:
    print ‘Backup Failed‘

当前文章:创新互联Python教程:Python如何调用rar命令
转载注明:http://cdysf.com/article/dhidogh.html