热线电话:13121318867

登录
2018-11-28 阅读量: 732
使用*运算符解压缩函数参数

*运算符提供了一种很艺术的方式来解压缩参数列表,参看如下示例:

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
0.0000
1
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子