过滤器: 1,list(filter(Function/None,[参数]))//将过滤返回为1为真的数 >>> list(filter(None,[1,0,False,True])) [1, True] >>> def odd(x): return x % 2 >>> temp = range(10)//0~9的数,不一定要用for循环来存储 >>> list(filter(odd,temp)) [1, 3, 5, 7, 9] >>> >>> list(filter(lambda x: x % 2,range(10))) [1, 3, 5, 7, 9] >>> 2,map() >>> a = ['11111','22222','33333','4444444'] >>> b = ['aaaaa','bbbbb','ccccc'] >>> print('pmzdkhs:',b[a.index('33333')])//index根据参数得到下标 pmzdkhs: ccccc
转载请注明原文地址: https://www.6miu.com/read-48586.html