其他分享
首页 > 其他分享> > 54.基础语法-元组

54.基础语法-元组

作者:互联网

tuple元组

创建单个元素的元组时需要注意细节

t_c0 = ()
print(type(t_c0))
t_c1 = (100)        #注意此创建方式新建的不是元组
print(type(t_c1))
t_c2 = (100, )
print(type(t_c2))
t_c3 = 100,
print(type(t_c3))
t_c4 = 100, 200, 300
print(type(t_c4))
t_c5 = tuple()
print(t_c5)

元组和列表的相互转换

t_z0 = (1, 2, 3)
print(list(t_z0))
t_z1 = [1, 2, 3]
print(tuple(t_z1))

元组的操作

标签:tuple,54,元组,语法,print,100,type,z3
来源: https://www.cnblogs.com/TK-tank/p/12345366.html