- debug:
var: my_list | select("greaterthan", 2) | list
vars:
my_list:
- "1"
- "2"
- "3"
Run Code Online (Sandbox Code Playgroud)
错误:'>' not supported between instances of 'str' and 'int'
我已经尝试过my_list | int | select("greaterthan", 2) | list,但没有给出预期的结果。
将列表的项目转换为整数。例如
- debug:
msg: "{{ my_list|map('int')|select('greaterthan', 2)|list }}"
vars:
my_list:
- "1"
- "2"
- "3"
Run Code Online (Sandbox Code Playgroud)
给出
"msg": [
3
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4678 次 |
| 最近记录: |