我有这段代码(foo
和 bar
是本地服务器):
env.hosts = ['foo', 'bar']
def mytask():
print(env.hosts[0])
当然,每次迭代都会打印 foo。
您可能知道,Fabric 遍历 env.hosts 列表并以这种方式在每个列表上执行 mytask():
fab mytask
会
task
在 foo
上执行
task
在 bar
我正在寻找一种在每次迭代中获取当前主机的方法。
谢谢,
最佳答案
使用 env.host_string
。您可以找到 env
变量的完整列表 here .
关于python - 使用 Python Fabric Library 获取 env.hosts 列表的当前值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3334936/