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]
热门推荐
10 恭祝新婚祝福语简短高级
11 小朋友祝福语简短暑假
12 新人红包祝福语简短精辟
13 结婚祝福语短句简短经典
14 男生老师蛋糕祝福语简短
15 18岁祝福语弟弟简短
16 中秋商务祝福语简短最新
17 哥哥生孩子祝福语简短
18 新年家人聚会祝福语简短