NumPy笔记:多维度数组

"""
    多维数组
"""
import numpy as np
 
print("--------------多维数组----------------")
data = np.array(3)
data1 = np.array([1, 2, 3, 4, 5, 6])
data2 = np.array([[1, 2, 3, 4, 5, 6]])
data3 = np.array([[[1, 2, 3, 4, 5, 6]]], dtype=float)
 
print("标量:", data, data.shape, type(data), data.dtype)
print("数组:", data1, data1.shape, type(data1), data1.dtype)
print("矩阵:", data2, data2.shape, type(data2), data2.dtype)
print("张量:", data3, data3.shape, type(data3), data3.dtype)

 

--------------多维数组----------------
标量: 3 () <class 'numpy.ndarray'> int32
数组: [1 2 3 4 5 6] (6,) <class 'numpy.ndarray'> int32
矩阵: [[1 2 3 4 5 6]] (1, 6) <class 'numpy.ndarray'> int32
张量: [[[1. 2. 3. 4. 5. 6.]]] (1, 1, 6) <class 'numpy.ndarray'> float64

 

 

上一篇:Python学习(九)三元运算、函数


下一篇:LTspice的下载和安装