# 左单右单
a = [1,2]
b = [3,4]
print(a) # [1, 2]
print(b) # [3, 4]
1.2 左单右多
# 左单右多
tuple1 = [1,2],[3,4]
print(tuple1) # ([1, 2], [3, 4])
tuple2 = (1,2),(3,4)
print(tuple2) # ((1, 2), (3, 4))
1.3 左多右单
# 左多右单
a,b = [[1,2],[3,4]]
print(a) # [1, 2]
print(b) # [3, 4]
a,b = ((1,2),(3,4))
print(a) # [1, 2]
print(b) # [3, 4]
1.4 左多右多
# 左多右多
a,b = [1,2],[3,4]
print(a) # [1, 2]
print(b) # [3, 4]
a,b = (1,2),(3,4)
print(a) # [1, 2]
print(b) # [3, 4]
二、右边是函数返回值
# 右边是函数返回值,情况实质也可归类于上面四种之一
# 比如函数返回值有多个的情况,下面这个例子就是左单右多
def func(x,y):
return x+y,x-y
tuple1=func(7,8)
print(tuple1) # (15, -1)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)