當前位置:
首頁 > 知識 > python中list,array,mat,tuple大小及類型

python中list,array,mat,tuple大小及類型

#coding: utf-8

from numpy import *

a=[1,2,3,4,5,6,7]

b=array([[1,2,3],[4,5,6]])

c=mat([[1,2,3],[4,5,6],[7,8,9]])

d=(0,2,4,5,6)

print("a:{}
type:{},shape:{}".format(a,type(a),shape(a)))

print("b:{}{}type:{},shape:{}".format(b,"
",type(b),shape(b)))

print("c:{}
type:{},shape:{}".format(c,type(c),shape(c)))

print("d:{}
type:{},shape:{}".format(d,type(d),shape(d)))

#結果如下

a:[1, 2, 3, 4, 5, 6, 7]

type:<class "list">,shape:(7,)

b:[[1 2 3]

[4 5 6]]

type:<class "numpy.ndarray">,shape:(2, 3)

c:[[1 2 3]

[4 5 6]

[7 8 9]]

type:<class "numpy.matrixlib.defmatrix.matrix">,shape:(3, 3)

d:(0, 2, 4, 5, 6)

type:<class "tuple">,shape:(5,)

python中list,array,mat,tuple大小及類型

打開今日頭條,查看更多精彩圖片
喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 程序員小新人學習 的精彩文章:

LINUX用戶管理和用戶組管理基礎
對vc++類和對象的逆向研究

TAG:程序員小新人學習 |