python3中返回迭代器:
函数map
def square(x):
return x ** 2
r = map(square, [1, 2, 3, 4, 5])
for i in r:
print(i)
lambda map
r = map(lambda x: x ** 2, [1, 2, 3, 4, 6])
for i in r:
print(i)
python3中返回迭代器:
def square(x):
return x ** 2
r = map(square, [1, 2, 3, 4, 5])
for i in r:
print(i)
r = map(lambda x: x ** 2, [1, 2, 3, 4, 6])
for i in r:
print(i)