导致以下输出的我的代码和数据结构如下所示:
Actions = set()
# loop through and obtain a list of files and commands
for item in d['server']:
Actions.add('{action}'.format(**item))
print(Actions)
commands = list(Actions)
commands = list(Actions)
输出:
Actions = {"{'command1': ['uptime'], 'path': ['/var/log/syslog']}", "{'command1': ['df -h'], 'path': ['/var/log/auth.log']}"}
我需要分别提取命令和路径,这样的事情不起作用。
print(commands[0]['command1'])
Traceback (most recent call last):
文件“read_shell_yaml.py”,第 46 行,在 print(commands[0]['command1']) 类型错误:字符串索引必须是整数
MMTTMM
湖上湖
相关分类