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 餐饮生日祝福语简短独特
16 鲜花英语祝福语卡片简短
17 男朋友暴富祝福语简短
18 婶婶拜年祝福语大全简短