2

When I am doing

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

It is copying fine

Same thing I am doing in 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))

But this code is throwing error that Invalid number of parameters

Is it a right way to invoke ? Any suggestion ?

Reuben
  • 5,556
  • 10
  • 43
  • 55

1 Answers1

5

There are spaces in your "source" and "target" pathnames. Try quoting it in the os.system call ie

output = os.system ("""xcopy "%s" "%s" """ % (source, target))
Vorsprung
  • 32,923
  • 5
  • 39
  • 63