我正在使用Python 2.6。检查以下链接后: Running shell command from Python and capturing the output 以下是我计划执行的代码:
import subprocess
# input: user email account
# output: mailing list which contain the user as an owner
def list_owners (usr_eml):
p = subprocess.Popen(['/usr/lib/mailman/bin/find_member','-w'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
out, err = p.communicate(usr_eml)
print out
m_list_usr_on = out.split( )
print m_list_usr_on
list_owners("my_email")
这段代码的输出是空的。 另一方面,如果我运行代码
/usr/lib/mailman/bin/find_member -w my_email
直接从shell命令,我得到了想要的结果。
你能给我解释一下可能的原因吗?
谢谢大家!
尝试在-w之后添加usr_eml:
相关问题 更多 >
编程相关推荐