我有一个如下所示的列表:
commands = [
{'command': "start app", 'action': "monitor", 'max-threshold': True, 'zero-failcount': True, 'started': True, 'stopped': False, 'failed': False},
{'command': "read log", 'action': "monitor", 'max-threshold': False, 'zero-failcount': True, 'started': True, 'stopped': False, 'failed': False},
{'command': "kill app", 'action': "monitor", 'max-threshold': True, 'zero-failcount': True, 'started': True, 'stopped': False, 'failed': False}
]
我想进行过滤,以便在新列表中只看到少数案例。例如,仅那些 max-threshold 为 true、zero-failcount true 等。我该如何做到这一点?我使用的是 Python 2.7。
最佳答案
关于python - 在Python中过滤具有许多键值对的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47692014/