1

Mighty people of Stackoverflow,

I want to execute

./namecoind name_new d/<name>

in a Python script with subprocess.popen where 'name' is a variable within the script. There are no spaces allowed between 'd/' and the variable. I tried this:

p = subprocess.Popen(["./namecoind", "name_new", "d/", domainname])

but this does not work, because this adds an ws between d/ and 'domainname'.

So, what to?

Thanks in advance!

Steffen

4

1 回答 1

3

空白不进入图片;subprocess.Popen如果您将列表传递给它(而不是字符串),则不会通过外壳程序,因此它不会在空格上拆分命令行。该参数只需要作为单个列表项发送:

p = subprocess.Popen(["./namecoind", "name_new", "d/" + domainname])
于 2013-04-20T19:49:11.080 回答