标签:type int for def list 调用 循环 列表 func
1.若给定一个列表a = [1, 2, [3, 4, [5, [6, 7, [8, [9, 10]]]]]],如何取到里面的每一个数
思路:可以用递归(自身调用)
a = [1, 2, [3, 4, [5, [6, 7, [8, [9, 10]]]]]] def func(x): for i in x: if type(i) is list: # 判断循环的结果是否是列表,若是则在循环一次 func(i) else: print(i) func(a)
标签:type int for def list 调用 循环 列表 func
原文地址:https://www.cnblogs.com/jiangxianseng/p/12148054.html