python中的列表与数组转换
2021-11-05 本文已影响0人
小白兔胡萝卜
将列表转换成数组或者数组转换成列表,操作如下(使用函数array 和 tolist):
from numpy import *
listS = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [20, 30, 40, 50, 60, 70, 80, 90, 100]]
print(listS)
temp_array = array(listS, dtype=object)
print(temp_array)
listR = temp_array.tolist()
print(listR)