使用Python在Windows下调用W
- import os
- import time
-
- source='C:\\Linda\\Test\\python\\source'
- target_dir='C:\\Linda\\Test\\Python\\backup\\'
-
- target=target_dir + time.strftime('%Y%m%d%H%M%S')+'.rar'
-
- print(target)
-
- rar_command = "winrar a %s %s"%(target,source)
- print (rar_command)
-
- if os.system(rar_command)==0:
- print ('Succeed to backup to', target)
- else:
- print ("Backup FaiLED")
相关文章