這篇我們要提到的是 : List
在程式裡頭 List 是不可或缺的儲存空間
首先,我們先開啟 Python 環境
宣告方法
list = [123, 45, 841, 112, "asd", 'ase']
就可以用以下的方法來測試囉~
這裡就先列出最常用的幾個方法 :
| 新增 | list.append( item) | 
| 插入參數 | list.insert( index, item ) | 
| 刪除( 參數 ) | list.remove( item ) | 
| 刪除( 位置 ) | list.pop( index ) | 
| 參數位置 | list.index( index ) | 
| 排序( 小到大 ) | list.sort() | 
| 排序( 大到小 ) | list.reverse() | 
| 參數存在個數 | list.count( value ) | 
| 陣列大小 | lenI( list ) | 
* : item ( 參數( 字串 / 數字 皆可 ) )、index( 索引 )
* : Python 是直譯式語言
以下是執行畫面 :

 
沒有留言:
張貼留言