日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python怎么建立全零數(shù)組

在python中,可以使用“numpy.zeros()”命令建立全零數(shù)組;語法為“numpy.zeros(shape,dtype=float,order='C')”。

創(chuàng)新互聯(lián)是一家專業(yè)提供新河企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、H5網(wǎng)站設(shè)計(jì)、小程序制作等業(yè)務(wù)。10年已為新河眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。

語句格式:

    numpy.zeros(shape, dtype=float, order='C')

參數(shù)說明:

    shape:整型或元素為整型的序列,表示生成的新數(shù)組的shape,如(2,3)或 2。

    dtype:生成數(shù)組的數(shù)據(jù)格式,如numpy.int8。默認(rèn)為numpy.float64。

    order:{'C', 'F'}可選,是否將多維數(shù)據(jù)存儲(chǔ)為C-或Fortran-contiguous(按行或按列)順序。

    返回值:ndarray,一個(gè)指定了shape, dtype, order的零數(shù)組。

示例見下:

    第四個(gè)例子看起來很方便。

Numpy文檔原文:

numpy.zeros
numpy.zeros(shape, dtype=float, order='C')
Return a new array of given shape and type, filled with zeros.
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
Whether to store multidimensional data in C- or Fortran-contiguous (row- or column-wise) order in memory.
Returns:
out : ndarray

Array of zeros with the given shape, dtype, and order.

#指定長度的一維數(shù)組
>>> np.zeros(5)
array([ 0.,  0.,  0.,  0.,  0.])

#指定數(shù)據(jù)類型,指定長度的一維數(shù)組
>>> np.zeros((5,), dtype=int)
array([0, 0, 0, 0, 0])

#二維數(shù)組
>>> np.zeros((2, 1))
array([[ 0.],
       [ 0.]])
       
>>> s = (2,2)
>>> np.zeros(s)
array([[ 0.,  0.],
       [ 0.,  0.]])
      
 #指定dtype
>>> np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')]) # custom dtype
array([(0, 0), (0, 0)],
      dtype=[('x', '

推薦課程:python語言設(shè)計(jì)(嵩天教授)


文章名稱:創(chuàng)新互聯(lián)Python教程:python怎么建立全零數(shù)組
網(wǎng)站地址:http://m.5511xx.com/article/ccdjgjg.html