Python元組tuple()
函數用於將專案列表轉換為元組。
語法
以下是tuple()
函數的語法 -
tuple( seq )
參數
- seq - 這是一個要轉換成元組的元組。
返回值
- 此函數返回元組最小值的元素。
例子
以下示例顯示了tuple()
函數的用法 -
#!/usr/bin/python3
list1= ['maths', 'che', 'phy', 'bio']
tuple1=tuple(list1)
print ("tuple elements : ", tuple1)
執行上面代碼,得到以下結果 -
tuple elements : ('maths', 'che', 'phy', 'bio')