python map 函数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Eric_LH/article/details/82150521
>>>def square(x) :            # 计算平方数
...     return x ** 2
... 
>>> map(square, [1,2,3,4,5])   # 计算列表各个元素的平方
[1, 4, 9, 16, 25]
a, b ="1+1i", "1+1i"  #str, str
a1, a2 = map(int, a[:-1].split('+'))
b1, b2 = map(int, b[:-1].split('+'))

猜你喜欢

转载自blog.csdn.net/Eric_LH/article/details/82150521