后浪云Python教程:Python如何调用rar命令
通过os模块的system()方法调用了系统的RAR.exe命令,这个方法会返回一个变量exit_status。
相关推荐:《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‘
版权声明:
作者:后浪云
链接:https://www.idc.net/help/168838/
文章版权归作者所有,未经允许请勿转载。
THE END