numpy参考文档:https://www.numpy.org.cn/reference/
# 1. 创建一维数组
import numpy as np
list1 = [1,2,3,4]
oneArray = np.array(list1)
print(type(oneArray)) #numpy.ndarray
print(oneArray) # [1 2 3 4]
print(oneArray.shape) # (4,)
print('*'*16)
t2 = np.array(range(10))
print(t2) #[0 1 2 3 4 5 6 7 8 9]
print(type(t2)) #numpy.ndarray
print('*'*16)
t3 = np.arange(0,10,2) #
print(t3) #[0 2 4 6 8]
print(type(t3)) #numpy.ndarray
# *****************************
# 2. 创建二维数组
import numpy as np
list2 = [[1,2],
[3,4],
[5,6]]
twoArray = np.array(list2)
print(twoArray)
#返回结果
'''
[[1 2]
[3 4]
[5 6]]
'''
# 3. 常用属性
list2 = [[1,2],[3,4],[5,6]]
twoArray = np.array(list2)
# 获取数组的维度
print(twoArray.ndim) # 2
# 形状
print(twoArray.shape) # (3, 2) 3行2列 (4,)则表示一维且有4个元素
# 有多少个元素 = shape[0] * shape[1]
print(twoArray.size) #6
# 4. 调整数组的形状
four = np.array([[1,2,3],[4,5,6]]) # (2,3) 2行3列
print(four)
'''
[[1 2 3]
[4 5 6]]
'''
# 修改的是原有的
four.shape = (3,2) # 变成3行2列
print