Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何从Fabric';什么地方指挥部?_Python_Python 2.7_Fabric_Stderr - Fatal编程技术网

Python 如何从Fabric';什么地方指挥部?

Python 如何从Fabric';什么地方指挥部?,python,python-2.7,fabric,stderr,Python,Python 2.7,Fabric,Stderr,Fabric v1.4.3未捕获“python--version”的输出 def python_v(): m = local('python --version', capture=True) print(m) localwithcapture=True返回命令的stdout;一个简单的测试显示,python--version在stderr上打印版本信息。因此,您可以尝试在命令中将stderr重定向到stdout: m = local('python --version 2&g

Fabric v1.4.3未捕获“python--version”的输出

def python_v():
    m = local('python --version', capture=True)
    print(m)

local
with
capture=True
返回命令的
stdout
;一个简单的测试显示,
python--version
stderr
上打印版本信息。因此,您可以尝试在命令中将
stderr
重定向到
stdout

m = local('python --version 2>&1', capture=True)

我发现以下方法比公认的答案更简洁:

print m.stderr


(谢谢你!)

或者使用:
print m.stderr
而不重定向