* nice * in subprocess.call函数不起作用

时间:2013-10-24 06:27:49

标签: python subprocess

我试过

>>> import subprocess
>>> import os
>>> subprocess.call(["echo","Hello there"], env=os.environ)
Hello there
0
>>> subprocess.call(["nice", "19", "echo","Hello there"], env=os.environ)
nice: 19: No such file or directory
127
>>> subprocess.call(["nice", "19", "echo","Hello there"], env=os.environ, shell=True)
0
0
>>>

我不明白为什么子进程无法识别 nice

我在shell中运行 nice 没有问题

  

$ nice -n 19 echo'hi there'

     

你好

1 个答案:

答案 0 :(得分:1)

您的"-n"电话中似乎忘记了subprocess.call的争论。你可能意味着

subprocess.call(["nice", "-n", "19", "echo", "Hello there"], env=os.environ)