Python特殊用法

1.若是要取最後一個元素,除了計算索引位置外,還能夠用-1作索引,直接獲取最後一個元素: classmates = [‘Michael’, ‘Bob’, ‘Tracy’]web classmates[-1] ‘Tracy’ 以此類推,能夠獲取倒數第2個、倒數第3個:編程 classmates[-2] ‘Bob’數據結構 classmates[-3] 2.另外一種有序列表叫元組:tuple。tupl
相關文章
相關標籤/搜索