我的问题是我有一个列表,其中包含一个列表,该列表也包含一个列表,我有这个
Toast.makeText(MainActivity.this,action + "", Toast.LENGTH_LONG).show();
但是如果我有该怎么办:
---
- hosts: localhost
gather_facts: no
vars:
families:
- surname: Smith
children:
- name: Mike
age: 4
- name: Kate
age: 7
- surname: Sanders
children:
- name: Pete
age: 12
- name: Sara
age: 17
tasks:
- name: List children
debug:
msg: "Family={{ item.0.surname }} Child={{ item.1.name }} Age={{ item.1.age }}"
with_subelements:
- "{{ families }}"
- children
我尝试了 ---
- hosts: localhost
gather_facts: no
vars:
families:
- surname: Smith
children:
- name: Mike
age: 4
nicknames:
- inside: XXX
outside: YYY
- name: Kate
age: 7
nicknames:
- inside: XXX
outside: YYY
- surname: Sanders
children:
- name: Pete
age: 12
- name: Sara
age: 17
nicknames:
- inside: XXX
outside: YYY
,其中包含3个条目,如下所示:
with_subelement
但是它没有用,并且给出了:
tasks:
- name: List children
debug:
msg: "Family={{ item.0.surname }} Child={{ item.1.name }} Inside-nickname={{ item.2.inside }}"
with_subelements:
- "{{ families }}"
- families.children
- families.children.nicknames
有没有什么想法可以遍历列表,而遍历列表又可以遍历列表?