2013-02-20 53 views
2

工作時我做的Windows XCOPY不蟒蛇

xcopy "D:\Accessories\My File\read-me.rtf" "D:\Any Folder\Destn" 

據複製我在python(2.7)

import os 
source = "D:\Accessories\My File\read-me.rtf" 
target = "D:\Any Folder\Destn" 
output = os.system ("xcopy %s %s" % (source, target)) 

做精

同樣的事情,但是這個代碼是投擲錯誤Invalid number of parameters

這是一個正確的方法來調用?任何建議?

回答

5

「源」和「目標」路徑名中有空格。嘗試在使用os.system調用引用它即

output = os.system ("""xcopy "%s" "%s" """ % (source, target)) 
+0

讓我CHK,我是用\「%s \」的 – Reuben 2013-02-20 08:46:42

+0

在我得到解析錯誤另一種情況嘗試。任何想法 ? – Reuben 2013-02-20 09:32:45