2018-03-18

python小知识

使用 * 运算符(splat operator)来 unpack 函数参数

*运算符(splat operator)提供了一个艺术化的方法来 unpack 参数列表,为清楚起见请参见下面的例子:

def test(x,y,z):
print(x,y,z)

testDict={'x':1,'y':2,'z':3}
testList=[10,20,30]

test(testDict)
test(
testDict)
test(
testList)

1-> x y z

2-> 1 2 3

3-> 10 20 30

你可能感兴趣的:(2018-03-18)