每次都将变量设置为对象。因此,变量将是最后一个匹配的对象。相反,将变量设置为空列表,然后将对象附加到该列表中。
mList = [] for m in data['info']: if m['subinfo']['sex'] == 'M': mList.append(m)