![图片[1]-python怎么把list变成array-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5e8d40535fc7e554.jpg)
将list转换成数组:
由于list中可以存放不同类型的元素,因此在转换成数组时,为了保证转换不出错,要检查类型是否一致,有数字且有字符的list转成array时会变成字符数组。
importnumpyasnp #definelist array=np.asarray(list) #thesecondmethod array=np.array(list,dtype=int)原文来自:https://www.py.cn
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END

![图片[1]-python怎么把list变成array-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5e8d40535fc7e554.jpg)
将list转换成数组:
由于list中可以存放不同类型的元素,因此在转换成数组时,为了保证转换不出错,要检查类型是否一致,有数字且有字符的list转成array时会变成字符数组。
importnumpyasnp #definelist array=np.asarray(list) #thesecondmethod array=np.array(list,dtype=int)原文来自:https://www.py.cn
暂无评论内容