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 道士结婚文案祝福语简短