我有下一个功能:
def render(self, src, **kwargs):
dict = self._tree_read(src, self.src_tree_path)
dict包含:
[('hosts', [{'username': 'test-user', 'url': 'http://example.com', 'hostname': 'test-host'}, {'username': 'test-user2', 'url': 'http://example.com2', 'hostname': 'test-host2'}])]
然后我尝试运行另一个bash脚本,并将参数从dict传递给它(dict中有两个配置,所以我需要运行子进程两次):
subprocess.call(["/bin/bash", "/opt/hosts.sh", "username", "url", "hostname"], shell=False)
但是没有成功,请帮助我。谢谢您!你知道吗
您所称的
dict
实际上是一个包含元组的列表,其中包含一个dict列表。你知道吗首先,
dict
是一个内置变量,不要重写它,请调用其他变量。你知道吗从那里,您可以迭代这些结果,以使用所需的值多次运行该子流程。你知道吗
相关问题 更多 >
编程相关推荐