class Foo(object): def __init__(self,name,data_list): self.name = name self.data_list = data_list def __iter__(self): yield "<div>" yield "全部" for item in self.data_list: yield item yield "</div>" obj_list = [Foo('富贵',['男','女']), Foo('强哥',['已报名','未报名']), Foo('熊平',['内部转介绍','百度推广'])] for obj in obj_list: for item in obj: print(item)