Python 程序将数组转换为具有相同元素的普通列表
给定一个数组。我们的任务是将数组转换为普通列表。我们借助 tolist() 函数解决该问题。该函数返回数组作为(可能嵌套的)列表。
算法
Step 1: Given an array. Step 2: convert the array to a list using tolist() function. Step 3: Display list
示例代码
#Python program to convert an array to an ordinary
#list with the same items
from array import *
def arraytolist(A):
lst = A.tolist() # list
print("The List Is ::>",lst)
# Driver code
A= array('i', [20,30,60]) # array
arraytolist(A)
输出
The List Is ::> [20, 30, 60] The List Is ::> [20, 30, 60]
廣告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Java 脚本
PHP