python 【序列拆包】sequence unpacking

  1. 比较少见
dic1 = {'a':1}
key, = dic1  # a
value, = dic1.values() # 1

#unpacking multiple dictionaries into single
x={1:"one",2:"two"}
y={3:"three",4:"four"}
z={5:"five",6:"six",7:"seven"}

a={**x,**y,**z,8:"eight",9:"nine"}
print(a)

x=[0,1,2,3]
y=[4,5,6,7,8,9]
#unpcking multiple list to one
z=[*x,*y]
print(z)

x={1,2,3,4}
y={9,8,7}
#unpacking multiple sets to one
z={*x,*y}
print(z)
原文地址:https://www.cnblogs.com/amize/p/14813776.html