1. 程式人生 > >week02_python內置數據結構__03

week02_python內置數據結構__03

小括號 pty tro str items 使用 ems 括號 數據

元組tuple

一個有序的元素組成的集合
使用小括號( ) 表示

元組是不可變對象

元組的定義 初始化

  • > 定義

    tuple() -> empty tuple
    tuple(iterable) -> tuple initialized from iterable‘s items

    t = tuple() #工廠方法
    t = ()
    t = tuple(range(1,7,2)) # iteratable
    t = (1,) # 一個元素元組的定義
    t = (1,)* 5 #(1, 1, 1, 1, 1)

week02_python內置數據結構__03