且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将2d列表转换为2d numpy数组?

更新时间:2021-09-16 00:15:46

只需将列表传递给np.array:

a = np.array(a)

如果默认值不是您想要的值,您还可以借此机会设置dtype.

You can also take this opportunity to set the dtype if the default is not what you desire.

a = np.array(a, dtype=...)