标签:class hub 有用 简单 输出 == 结果 for 合并
感谢莫烦老师
详情
a = [1, 2, 3]
b = [4, 5, 6]
zip(a,b)
# <zip at 0x1d72cf30bc8>
print(list(zip(a, b))) # [(1, 4), (2, 5), (3, 6)]
print(list(zip(a, a, b))) # [(1, 1, 4), (2, 2, 5), (3, 3, 6)]
for i, j in zip(a, b):
print(i/2, j*2)
# 0.5 8
# 1.0 10
# 1.5 12
print(list(zip(a, a, b))) # [(1, 1, 4), (2, 2, 5), (3, 3, 6)]
def f1(x, y):
return x + y
f2 = lambda x, y: x + y
print(f1(1, 2)) # 3
print(f2(1, 2)) # 3
print(list(map(f1, [1], [2]))) # x=1, y=2
print(list(map(f2, [2, 3], [4, 5]))) # [6, 8] 第一个表示将2+4 第二个表示3+5
标签:class hub 有用 简单 输出 == 结果 for 合并
原文地址:https://www.cnblogs.com/cloud-ken/p/12628438.html