将列表元素提升为幂
发布于 2021-01-29 16:53:48
如何将列表中的数字提高到一定的幂数?
关注者
0
被浏览
48
1 个回答
-
使用清单理解:
def power(my_list): return [ x**3 for x in my_list ]
https://docs.python.org/3.4/tutorial/datastructures.html#list-
comprehensions