Python查看多维数组List的维度

方法

直接用len()函数只能得到数组最外面一层的维度。

因此,先把list转成numpy数组,再用numpy数组的shape属性获取数组维度。

import numpy as np

list = [[1,2],
        [3,4],
        [5,6]]
dimen = np.array(list).shape
print(dimen)
输出:
(3, 2)

参考感谢

[1] https://blog.csdn.net/scut_salmon/article/details/78833704

猜你喜欢

转载自blog.csdn.net/xiangduixuexi/article/details/107002571
今日推荐