Checkthis's Notes
2017年9月30日 星期六
Python - Tuple筆記
Tuple與List相似,最大的不同即是Tuple內的值不可以更改,否則會發生錯誤
宣告方式
t = ()
t = (1, 2, 3, 4)
利用索引值取出Tuple內的值
print(t(1)) # 2
利用list()轉換成串列
print(list(t)) # [1, 2, 3, 4]
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言