我正在尝试运行:
try:
with open(subprocess.PIPE, 'w') as pipe:
call(["/usr/sbin/atms","-k"], stdout=pipe, stderr=pipe)
call(["/usr/sbin/atms","/usr/sbin/atms.conf"],stdout=pipe,stder=pipe)
except Exception, e:
print e
我现在明白了
coercing to Unicode: need string or buffer, int found
这是什么意思?
谢谢
最佳答案
open()
用于文件,并且需要文件名而不是管道。
您可以使用 Popen
而不是 .call()
:
>>> p = subprocess.Popen(['python', '-c', 'print "test"'], stdout=subprocess.PIPE)
>>> p.stdout.read()
'test\r\n'
关于python - 在Python子进程中运行call()时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14182780/