📜  数组的力量 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:09.092000             🧑  作者: Mango

代码示例1
>> import numpy as np 

>> x1 = np.arange(6)

>> x1
[0, 1, 2, 3, 4, 5]

>> np.power(x1, 3)
array([  0,   1,   8,  27,  64, 125])

# allso works with raising one array to the power of another 
>> x2 = np.array([[1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1]])

>> x2
array([[1, 2, 3, 3, 2, 1],
       [1, 2, 3, 3, 2, 1]])

>> np.power(x1, x2)
array([[ 0,  1,  8, 27, 16,  5],
       [ 0,  1,  8, 27, 16,  5]])