numpy.tolist( )函數


官方文檔:https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tolist.html?highlight=numpy%20tolist

 

 

numpy.ndarray.tolist method ndarray.tolist() Return the array as an a.ndim-levels deep nested list of Python scalars. nested:嵌套的 Return a copy of the array data as a (nested) Python list. Data items are converted to the nearest 
compatible builtin Python type, via the item function.
以(嵌套的)Python列表的形式返回數組數據的副本。通過item函數,將數據項轉換為Python中最接近的兼容內置類型。(有道)
If a.ndim
is 0, then since the depth of the nested list is 0, it will not be a list at all, but a simple
Python scalar. Parameters: none Returns: y :
object, or list of object, or list of list of object, or … The possibly nested list of array elements. 數組元素的嵌套列表

Notes:

The array may be recreated via np.array(a.tolist()), although this may sometimes lose precision.

官網例子截圖:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM