import numpy as np
a = np.array([[1 ,2 ,4 ,5 ,3],
[51,86,43,29,64]])
b = np.ones(shape) #根据shape生成一个全1数组,shape是元组类型
c = np.zeros(shape) #根据shape生成一个全0数组,shape是元组类型
b = np.ones((3,6))
b = np.ones([3,6])
@set_module('numpy')
def ones(shape, dtype=None, order='C'):
"""
Return a new array of given shape and type, filled with ones.
Parameters
----------
shape : int or sequence of ints
Shape of the new array, e.g., ``(2, 3)`` or ``2``.
dtype : data-type, optional
The desired data-type for the array, e.g., `numpy.int8`. Default is
`numpy.float64`.
order : {'C', 'F'}, optional, default: C
Whether to store multi-dimensional data in row-major
(C-style) or column-major (Fortran-style) order in
memory.
Returns
-------
out : ndarray
Array of ones with the given shape, dtype, and order.