Python List len()方法
Python List len()方法
len() 方法返回列表元素個數。
語法
len()方法語法:
len(list)
參數
- list -- 要計算元素個數的列表。
返回值
返回列表元素個數。
實例
以下實例展示了 len()函數的使用方法:
#!/usr/bin/python list1, list2 = [123, 'xyz', 'zara'], [456, 'abc'] print "First list length : ", len(list1); print "Second list length : ", len(list2);
以上實例輸出結果如下:
First list length : 3 Second lsit length : 2
相關文章
- Python continue 語句
- Python 日期和時間
- Python 面向對象
- Python 正則表達式
- Python 搜索樹
- Python 回溯
- Python 大O符號
- Python3 環境搭建
- Python3 集合(Set)
- Python3 迭代器
- Python max() 函數
- Python uniform() 函數
- Python File next() 方法
- Python File truncate() 方法
- Python os.chdir() 方法
- Python os.lchflags() 方法
- Python os.major() 方法
- Python maketrans()方法
- Python List append()方法
- Python 字典 Dictionary items()方法