Python3循环遍历所有列表和元组

时间:2014-08-08 03:04:48

标签: python for-loop python-3.x dictionary

假设我有一个包含多个列表和元组的字典,我想循环遍历所有字典的项目,并且还遍历所有字典的元组和列表(以便只获取值和关键字)有没有办法做到这一点,而不仅仅是定义一堆for循环?

即:

def islist(arg):
    if type(arg) == list or tuple:
        #loop
        for i in arg:
            if type(i) == list or tuple:
                #again
                for i in arg:
                    if type(i) == list or tuple:
                        #again

0 个答案:

没有答案