📜  Python| numpy ndarray.__ipow__()

📅  最后修改于: 2022-05-13 01:54:37.068000             🧑  作者: Mango

Python| numpy ndarray.__ipow__()

Numpy ndarray.__ipow__()方法的帮助下,我们将使用numpy.ndarray.__ipow__()方法中作为参数提供的值来获取所有元素。

示例 #1:
在这个例子中,我们可以看到每个元素都使用ndarray.__ipow__()方法中作为参数提供的值。

# import the important module in python
import numpy as np
      
# make an array with numpy
gfg = np.array([1, 2, 3, 4, 5])
      
# applying ndarray.__ipow__() method
print(gfg.__ipow__(3))
输出:
[  1   8  27  64 125]

示例 #2:

# import the important module in python
import numpy as np
      
# make an array with numpy
gfg = np.array([[1, 2, 3, 4, 5],
                [6, 5, 4, 3, 2]])
      
# applying ndarray.__ipow__() method
print(gfg.__ipow__(2))
输出:
[[ 1  4  9 16 25]
 [36 25 16  9  4]]