Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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:
local
capture=True
stdout
python --version
stderr
m = local('python --version 2>&1', capture=True)
我发现以下方式比接受的答案更干净:
print m.stderr
(谢谢雷莫苏!)