Python之Numpy

一只码畜 2020-03-01

1.数组

array()

...import numpy as np
...a=np.array(range(12))        #array()创建数组
...print(a)
[0,1,2,3,4,5,6,7,8,9,10,11]

a.shape()

...a.shape                       #shape查看属性
(12,)                            #数组长度为12
...a.shape=2,3                   #改成2行3列二维结构
...print(a)               
[[0,1,2,3,4,5]
 [6,7,8,9,10,11]]
...a.shape=2,2,3                 #改成2组2行3列三维结构[[[0,1,2]  [3,4,5]][[6,7,8] [9,10,11]]]

arange()

相关推荐

petal0 / 0评论 2020-06-10