有人可以告诉我如何从stdout_lines中删除空值吗?
输出
"stdout_lines": [
"",
"D:\Program Files\Apache Softwarecoder.exe",
"",
"D:\Program Files\Apache Software\cat8.5.exe",
"",
"",
""
]
预期输出
"stdout_lines": [
"D:\Program Files\Apache Softwarecoder.exe",
"D:\Program Files\Apache Software\cat8.5.exe"
]
我尝试如下
path: "{{test.stdout_lines | rejectattr('') }}"
path: "{{test.stdout_lines | reject('')|list }}"
path: "{{test.stdout_lines | rejectattr('')|list }}"
但是我收到以下错误或输出没有变化:
"path": "<generator object _select_or_reject at 0x7fb349f45cd0>"
拒绝完成工作
path: "{{ stdout_lines|reject('match', '^$')|list }}"
以及选择
path: "{{ stdout_lines|select('match', '.+')|list }}"