Latest web development tutorials

Python List list()方法

Python 列表 Python列表


描述

list() 方法用於將元組轉換為列表。

注:元組與列表是非常類似的,區別在於元組的元素值不能修改,元組是放在括號中,列表是放於方括號中。

語法

list()方法語法:

list( seq )

參數

  • list -- 要轉換為列表的元組。

返回值

返回列表。

實例

以下實例展示了list()函數的使用方法:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

aTuple = (123, 'xyz', 'zara', 'abc');
aList = list(aTuple)

print "列表元素 : ", aList

以上實例輸出結果如下:

列表元素 :  [123, 'xyz', 'zara', 'abc']

Python 列表 Python列表