其他分享
首页 > 其他分享> > 5_元组

5_元组

作者:互联网

a = (1, 2, 3, 4, 5, "上山打老虎")
# (1, 2, 3, 4, 5, '上山打老虎')
print(a)
# 4
print(a[3])
# (1, 2, 3, 4, 5, '上山打老虎')
print(a[:])
# (1, 3, 5)
print(a[::2])
# ('上山打老虎', 5, 4, 3, 2, 1)
print(a[::-1])

s = (1, 2, 3)
t = (4, 5, 6)
w = (s, t)
# (1, 2, 3, 4, 5, 6)
print(s+t)
# ((1, 2, 3), (4, 5, 6))
print(w)
b = (123, "我爱你", "你爱我吗", 99999)
x, y, z, m = b
# 123  我爱你   你爱我吗    99999
print(x, "\n",  y, "\n", z, "\n", m)
x, y = 10, 20
print(x)
print(y)

 

标签:99999,上山,老虎,爱我吗,123,print,元组
来源: https://www.cnblogs.com/tuyin/p/16552711.html