Python| Numpy np.legzero() 方法
可以使用np.legzero()
方法代替np.zeros来创建元素为 0 的数组。
Syntax : np.legzero()
Return : Return array([0])
示例 #1:
# Python program explaining
# numpy.legzero() method
# import numpy and legzero
import numpy as np
from numpy.polynomial.legendre import legzero
# using np.legzero() method
ans = legzero
print(ans)
输出 :
[0]
示例 #2:
# Python program explaining
# numpy.legzero() method
# import numpy and legzero
import numpy as np
from numpy.polynomial.legendre import legzero
# using np.legzero() method
ans = legzero + [[1, 3, 5], [2, 4, 6]]
print(ans)
输出 :
[[1 3 5]
[2 4 6]]