python list numpy array 互转

list1 = [1,2,3,4,5]

列表转numpy数组

import numpy as np
array1 = np.array(list1)
array1

array([1, 2, 3, 4, 5])

numpy数组转python列表

list2 = array1.tolist()
list2

[1, 2, 3, 4, 5]

猜你喜欢

转载自blog.csdn.net/weixin_44493841/article/details/121331171