windows 上python程序如何去用有关系统的命令行 例如:备份文件

windows 下python程序怎么去用有关系统的命令行 例如:备份文件
我仿照写了个备份python,但不能成功:
# Filename: backup_ver1.py

import os
import time

# 1. The files and directories to be backed up are specified in a list.
source = r'D:\pythonfile\test'
# If you are using Windows, use source = [r'C:\Documents', r'D:\Work'] or something like that

# 2. The backup must be stored in a main backup directory
target_dir = r'D:\pythonfile' # Remember to change this to what you will be using

# 3. The files are backed up into a zip file.
# 4. The name of the zip archive is the current date and time
target = target_dir + time.strftime('%Y%m%d%H%M%S') + '.rar'

# 5. We use the zip command (in Unix/Linux) to put the files in a zip archive
zip_command = "WINRAR A %s %s -r" % (target,source)

# Run the backup
if os.system(zip_command) == 0
  print 'Successful backup to', target
else:
  print 'Backup FAILED' 
raw_input ("dd")
WINRAR 是网上找的一个命令,但运行报错:
D:\pythonfile>backup_ver1.py
  File "D:\pythonfile\backup_ver1.py", line 21
  if os.system(zip_command) == 0
  ^
SyntaxError: invalid syntax
这是为什么呢?求大神指点,指点在windows下python的脚本写法。。。怎么去火的windows的命令行


------解决方案--------------------
路径有空格你要加双引号,类似:
zip_command = r'"C:\Program Files\WinRAR\WinRAR.exe" A "%s" "%s" -r' % (target,source)
------解决方案--------------------
os.system(r'"C:\Program Files\HaoZip\HaoZip.exe"')#加了双引号之后的路径就应该没有问题啊
------解决方案--------------------
探讨
引用:

引用:

引用:

路径有空格你要加双引号,类似:
zip_command = r'"C:\Program Files\WinRAR\WinRAR.exe" A "%s" "%s" -r' % (target,source)

还是不行:
'C:\Program' 不是内部或外部命令,也不是可运行的程序
或批处理文件……