元祖基礎
阿新 • 來源:網路 • 發佈:2021-02-18
技術標籤:python學習
#元祖與列表基本上是一樣的,只是元祖不可變,列表可以改變
tuple=(10,20,30,'abc','123',[1,2,3])
print(len(tuple))#6
print(10 in tuple)#True
print(tuple[2])#30
print(tuple[3])#abc
print(tuple[3:5])#('abc','123')
#tuple[-1]=100
print(tuple[::-1])
輸出:

