首页 > 代码库 > Python:元组(tuple)

Python:元组(tuple)

#!/usr/bin/python3#元组tup1 = (Google, Runoob, 1997, 2000)print(type(tup1))print("tup1 ",tup1)#创建空元组tup2 = ()#创建一个元素 一定要用 ,tup3 = (4,)print(type(tup3))#修改元组  元组里面的元素是不允许修改的#修改是非法的,无效的#tup1[0] = "update"print("tup1[0]",tup1[0])tup1 = tup1 + tup3print("tup1 ",tup1)#删除元组#del tup1print("len(tup1) ",len(tup1))#max min#tuple(list) 将列表转元组

 

Python:元组(tuple)