欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python中numpy.zeros(np.zeros)的使用方法

 更新時間:2017年11月07日 09:19:36   投稿:jingxian  
下面小編就為大家?guī)硪黄猵ython中numpy.zeros(np.zeros)的使用方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

翻譯:

用法:zeros(shape, dtype=float, order='C')

返回:返回來一個給定形狀和類型的用0填充的數(shù)組;

參數(shù):shape:形狀

dtype:數(shù)據(jù)類型,可選參數(shù),默認(rèn)numpy.float64

dtype類型:

t ,位域,如t4代表4位

b,布爾值,true or false

i,整數(shù),如i8(64位)

u,無符號整數(shù),u8(64位)

f,浮點數(shù),f8(64位)

c,浮點負(fù)數(shù),

o,對象,

s,a,字符串,s24

u,unicode,u24

order:可選參數(shù),c代表與c語言類似,行優(yōu)先;F代表列優(yōu)先

例子:

np.zeros(5)
array([ 0., 0., 0., 0., 0.])


np.zeros((5,), dtype=np.int)
array([0, 0, 0, 0, 0])


np.zeros((2, 1))
array([[ 0.],
    [ 0.]])


s = (2,2)
np.zeros(s)
array([[ 0., 0.],
    [ 0., 0.]])


np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')]) # custom dtype
array([(0, 0), (0, 0)],
   dtype=[('x', '<i4'), ('y', '<i4')])


########################################################

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.


See Also
--------
zeros_like : Return an array of zeros with shape and type of input.
ones_like : Return an array of ones with shape and type of input.
empty_like : Return an empty array with shape and type of input.
ones : Return a new array setting values to one.
empty : Return a new uninitialized array.


Examples
--------
np.zeros(5)
array([ 0., 0., 0., 0., 0.])


np.zeros((5,), dtype=np.int)
array([0, 0, 0, 0, 0])


np.zeros((2, 1))
array([[ 0.],
    [ 0.]])


s = (2,2)
np.zeros(s)
array([[ 0., 0.],
    [ 0., 0.]])


np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')]) # custom dtype
array([(0, 0), (0, 0)],
   dtype=[('x', '<i4'), ('y', '<i4')])
Type:   builtin_function_or_method

以上這篇python中numpy.zeros(np.zeros)的使用方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • python中單例常用的幾種實現(xiàn)方法總結(jié)

    python中單例常用的幾種實現(xiàn)方法總結(jié)

    Python 的模塊就是天然的單例模式,下面這篇文章主要給大家介紹了關(guān)于python中單例常用的幾種實現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用python單例具有一定的參考學(xué)習(xí)價值,需要的朋友們一起來看看吧
    2018-10-10
  • python簡單實現(xiàn)獲取當(dāng)前時間

    python簡單實現(xiàn)獲取當(dāng)前時間

    最近項目中經(jīng)常需要python去取當(dāng)前的時間,雖然不是很難,但是老是忘記,用一次丟一次,為了能夠更好的記住,我今天特意寫下python 當(dāng)前時間這篇文章,如果你覺的對你有用的話,可以收藏下。
    2016-08-08
  • Python中asyncio模塊使用詳解

    Python中asyncio模塊使用詳解

    Python中的asyncio模塊提供了異步IO支持,通過協(xié)程和事件循環(huán)實現(xiàn)異步編程,使用裝飾器@asyncio.coroutine可以定義協(xié)程,yield from語法用于調(diào)用其他協(xié)程并實現(xiàn)非阻塞等待,asyncio.sleep()模擬IO操作,通過并發(fā)執(zhí)行多個協(xié)程提高程序性能
    2024-10-10
  • python多重繼承實例

    python多重繼承實例

    這篇文章主要介紹了python多重繼承實例,簡單實用易于理解,需要的朋友可以參考下
    2014-10-10
  • python如何實現(xiàn)wifi自動連接,解決電腦wifi經(jīng)常斷開問題

    python如何實現(xiàn)wifi自動連接,解決電腦wifi經(jīng)常斷開問題

    這篇文章主要介紹了python實現(xiàn)wifi自動連接,解決電腦wifi經(jīng)常斷開的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • python for循環(huán)內(nèi)輸出和外輸出方式

    python for循環(huán)內(nèi)輸出和外輸出方式

    這篇文章主要介紹了python for循環(huán)內(nèi)輸出和外輸出方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-03-03
  • python select.select模塊通信全過程解析

    python select.select模塊通信全過程解析

    這篇文章主要為大家解析了python select.select模塊通信全過程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-09-09
  • Python read函數(shù)按字節(jié)(字符)讀取文件的實現(xiàn)

    Python read函數(shù)按字節(jié)(字符)讀取文件的實現(xiàn)

    這篇文章主要介紹了Python read函數(shù)按字節(jié)(字符)讀取文件的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • python爬蟲-模擬微博登錄功能

    python爬蟲-模擬微博登錄功能

    這篇文章主要介紹了python爬蟲-模擬微博登錄功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-09-09
  • python編程項目中線上問題排查與解決

    python編程項目中線上問題排查與解決

    因為業(yè)務(wù)上的設(shè)計存在問題,導(dǎo)致數(shù)據(jù)庫表總是被鎖,而且是不定期的鎖定,導(dǎo)致服務(wù)器運行異常,今天就來跟大家說說該如何避免這種問題
    2021-11-11

最新評論