*args 与**kwargs

= L1 [1,2,3,4 ] 
T1 = (1,2,3,4 ) 
D1 = { ' name ' : ' Tank ' , ' Age ' : 73 is }
 Print (* L1) beaten list 123 . 4 
 Print (* T1) broken tuple. 3 2. 4. 1
 Print (* D1) only get broken dictionary name age Key 
Print (** D1) # error
DEF bar (* args, ** kwargs): # here only break value Print (args) # args tuple (. 1, 2,. 3) Print (kwargs) kwargs dictionary # { 'D': 10, 'E': 20 is, 'F': 30} bar ( . 1, 2, 3, d = 10, e = 20, f = 30)

1 2 3 4
1 2 3 4
name age
(1, 2, 3)
{'d': 10, 'e': 20, 'f': 30}

Guess you like

Origin www.cnblogs.com/bigbox/p/12070899.html
Recommended