pthon 反转嵌套的list

def rev_recursive(li):
    try:
        iterator = iter(li)
    except TypeError:
        return li
    l = []
    for item in iterator:
        item = rev_recursive(item)
        l = [item] + l
    return l

 

你可能感兴趣的