python 怎么快速获取嵌套列表内的每一个元素? 10
aa=[[(55736,)],[(55739,)],[(55740,),(55801,)],[(55748,)],[(55783,),(55786,),(55787,),...
aa = [[(55736,)], [(55739,)], [(55740,), (55801,)], [(55748,)], [(55783,), (55786,), (55787,), (55788,)], [(55817,), (55821,)], [(55818,)]]
如列表aa内嵌套列表,里面又由不同个数元素的元组组成,怎么可以快速获取列表内的每一个元素呢? 展开
如列表aa内嵌套列表,里面又由不同个数元素的元组组成,怎么可以快速获取列表内的每一个元素呢? 展开
2个回答
展开全部
aa = [[(55736,)], [(55739,)], [(55740,), (55801,)], [(55748,)], [(55783,), (55786,), (55787,), (55788,)], [(55817,), (55821,)], [(55818,)]]
def getelement(aa):
for elem in aa:
if type(elem)==type([]):
for element in getelement(elem):
yield element
else:yield elem
for elem in getelement(aa):print(elem)(55736,)
(55739,)
(55740,)
(55801,)
(55748,)
(55783,)
(55786,)
(55787,)
(55788,)
(55817,)
(55821,)
(55818,)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询