numpy
的shape
函数用于输出数组的维度。
import numpy as np
a = np.array([1, 2, 3, 4])
print("a.shape =", a.shape)
b = np.array([(1, 2), (3, 4)])
print("b.shape =", b.shape)
执行结果:
a.shape = (4,)
b.shape = (2, 2)
numpy
的shape
函数用于输出数组的维度。
import numpy as np
a = np.array([1, 2, 3, 4])
print("a.shape =", a.shape)
b = np.array([(1, 2), (3, 4)])
print("b.shape =", b.shape)
执行结果:
a.shape = (4,)
b.shape = (2, 2)