递归 递归: # 函数在调用阶段直接或间接地又调用了自身 应用场景: # 将列表中的数字依次打印出来(循环的层数是你必须要考虑的点) --> l = [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, ]]]]]]]]]]]]] # 循环的写法, 列表嵌套越多层越麻烦 for i in l: # 推导思路 if type(i) is int: print(i) else: for item in i: if type(item)…
一.数据筛选: 处理方式: 1.filter函数在py3,返回的是个生成式. from random import randint data = [randint(-100,100) for i in range(10)] data2 = [34, -59, -13, 96, -78, 38, 89, -96, -79, 98] info = filter(lambda x:x>0,data2) for i in info: print(i) 2.列表解析 from random import…