将list转换成数组: 由于list中可以存放不同类型的元素,因此在转换成数组时,为了保证转换不出错,要检查类型是否一致,有数字且有字符的list转成array时会变成字符数组。 import numpy as np # define list array = np.asarray(list) #the second method array = np.array(list, dtype = int) 更多Python知识请关注Python视频教程栏目。