python 元组和字典如何拆包

元组拆包

def num():
	return 100,200
a,b = num()
print(a)#100
print(b)#200


字典拆包

a = {'a':1,'b':2}
b,c = a
print(b)#'a'
print(c)#'b'
print(a[b])#1
print(a[c])#2

发布了14 篇原创文章 · 获赞 4 · 访问量 586

猜你喜欢

转载自blog.csdn.net/weixin_43273113/article/details/103924988