【python】list类型与数组array类型的互相转换

简介: list和array相互转换

1. list ---> array

代码:

#导入numpy包
import numpy as np
#假设A为list类型数据
res_arr = np.array(A) # 将A转为数组类型,得到res_arr

2. array--->list

代码:

# 假设B是numpy中的数组array类型
res_list = B.tolist() # 将B转为list类型,得到res_list
相关文章
|
23天前
|
Python IDE 开发工具
Python类型注解(十)
Python类型注解(十)
34 0
Python类型注解(十)
|
1月前
|
存储 程序员 Python
Python变量类型
Python变量类型
15 0
|
2月前
|
测试技术 API Python
Python 3.10 的首个 PEP 诞生,内置类型 zip() 迎来新特性
Python 3.10 的首个 PEP 诞生,内置类型 zip() 迎来新特性
44 2
|
1月前
|
Python
【python】—— 内置类型、运算符、表达式、关键字
【python】—— 内置类型、运算符、表达式、关键字
107 1
|
3天前
|
索引 Python
python 格式化、set类型和class类基础知识练习(上)
python 格式化、set类型和class类基础知识练习
23 0
|
12天前
|
索引 Python
Python标准数据类型-List(列表)
Python标准数据类型-List(列表)
41 1
|
17天前
|
存储 Python
python基础篇: 详解 Python 字典类型内置方法
python基础篇: 详解 Python 字典类型内置方法
26 1
|
1月前
|
安全 Python
Python系列(16)—— string类型转float类型
Python系列(16)—— string类型转float类型
|
1月前
|
Python
Python系列(15)—— int类型转string类型
Python系列(15)—— int类型转string类型
|
1月前
|
存储 安全 Java
Python教程第3章 | 集合(List列表、Tuple元组、Dict字典、Set)
Python 列表、无序列表、字典、元组增删改查基本用法和注意事项
50 1

热门文章

最新文章