使用 tolist() 方法将数组转换为具有相同元素的 python 列表

当你需要 Python list 对象时,可以使用 tolist() 方法将数组转换为列表。

my_array = array('i', [1,2,3,4,5])
c = my_array.tolist()
# [1, 2, 3, 4, 5]