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 爱生日祝福语简短独特