import numpy as np a = [[1, 2], [3, 4], [5, 6]] b = np.array(a) len(a) # 3 len(b) # 3 np.size(a) # 3 np.size(a, 0) # 3 np.size(a, 1) # err b.size # 6 np.size(b) # 6 np.size(b, 0) # 3 np.size(b, 1) # 2 np.shape(a) # (3,) b.shape # (3, 2) np.shape(b) # (3, 2) b.dtype # dtype('int32') c = [[1, 2], [3, 4], [5, 6, 7]] d = np.array(c) len(c) # 3 len(d) # 3 np.size(c) # 3 np.size(c, 0) # 3 np.size(c, 1) # err d.size # 3 np.size(d) # 3 np.size(d, 0) # 3 np.size(d, 1) # err np.shape(c) # (3,) d.shape # (3,) np.shape(d) # (3,) d.dtype # dtype('O')
shape返回元组,size返回dtype的总数