【发布时间】:2013-07-26 16:38:48
【问题描述】:
我试图使用子进程调用来执行复制操作(代码如下):
import subprocess
pr1 = subprocess.call(['cp','-r','./testdir1/*','./testdir2/'], shell = True)
我收到一条错误消息:
cp: missing file operand
Try `cp --help' for more information.
当我尝试使用 shell=False 时,我得到了
cp: cannot stat `./testdir1/*': No such file or directory
我该如何解决这个问题?
我正在使用 RedHat Linux GNOME Deskop 版本 2.16.0 和 bash shell 和 Python 2.6
附:我阅读了Problems with issuing cp command with Popen in Python 中发布的问题,它建议使用shell = True 选项,正如我提到的那样,这对我不起作用:(
【问题讨论】:
标签: python subprocess cp