#Tuple(元祖)
#tuple的元素不能修改,但可以包含可變元素
#tuple用’()'包裹,元素之間用逗號分隔
#01 使用可迭代元素創建元祖
#tuple(iterable=(), /)
#使用()創建僅包含一個元素的元祖時需要在元素後添加’,'防止將()認定為表達式
tp01 = (1,2,3,4,5)
tp = (1,)
#02 獲取元素索引
#index(self, value, start=0, stop=9223372036854775807, /)
tp02 = (0,1,2,3,4,5,6,7)
tp = tp02.index(3)
#03 獲取指定元素出現次數
#count(self, value, /)
tp03 = (0,1,2,3,4,5,6,7)
tp = tp03.count(8)
#04 使用下標獲取元素
tp04 = (0,1,2,3,4,5,6,7)
tp = tp04[5]
#05 使用下標切片
tp05 = (0,1,2,3,4,5,6,7)
tp = tp05[:5]
#06 元祖的拼接
tp06 = ('a','b','c')
tp = tp05 + tp06
#07 元素判斷
tp07 = (0,1,2,3,4,5,6,7)
if 0 in tp07:
print('in')
print(tp)