递归
定义:递归包括递进和回归
递归深度
查看
def foo(n): print(n) n=n+1 foo(n) foo(1)
修改
import sys print(sys.setrecursionlimit(100000))
案例
示例1
list2 = [11, 22, [33, 44], [55, [66, 77]], [88, [99, [100, [200, [300]]]]]] list3=[11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 200, 300] ''' 把list2转成list3 ''' def f(li): ret=[] for i in li: if isinstance(i,list): for j in f(i): ret.append(j) else: ret.append(i) return ret print(f(list2))