这就是我想要实现的目标
def fun():
runner = InteractiveConsole()
while(True):
code = raw_input()
code.rstrip('\n')
# I want to achieve the following
# By default the output and error of the 'code' is sent to STDOUT and STDERR
# I want to obtain the output in two variables out and err
out,err = runner.push(code)
到目前为止,我查看的所有解决方案都使用任一管道发出单独的脚本执行命令(在我的情况下这是不可能的)。还有其他方法可以实现吗?