ret = zip([1,2,3,4,5],('a','b','c','d'),(4,5)) #拉链方法
print(ret)
for i in ret:
print(i)
lst = [1, 4, 6, 7, 9, 12, 17]
def func(num):
if num % 2 == 0:return True
filter(func,lst)
for i in filter(func,lst):
print(i)
g = (i for i in lst if i%2 == 0)
l = ['test', None, '', 'str', ' ', 'END']
def func(item):
if item and item.strip():return True
for i in filter(func,l):
print(i)
[i**2 for i in range(10)]
def func(num):
return num ** 2
for i in map(func,range(10)):print(i)
排序功能
l = [1,-4,-2,3,-5,6,5]
l.sort(key=abs)
print(l)
l = [1,-4,-2,3,-5,6,5]
new_l = sorted(l,key=abs,reverse=True)
print(new_l)
l = [[1,2],[3,4,5,6],(7,),'123']
# print(sorted(l,key=len))
eval()
eval('print(123)')
exec('print(123)')
print(eval('1+2-3*20/(2+3)'))
print(exec('1+2-3*20/(2+3)'))
内置函数
标红的如果不会
标黄的 是能够节省你的代码 面试会用
min max sorted filter map 面试明星知识点
你经常不见 且没被点名说重点的 就不用特别了解了