def sum(a, b, c):
return a + b + c
a = [1, 2, 3]
# the * unpack list a
print sum(*a)
>> 6
def sum(a, b, c):
return a + b + c
a = {'a': 1, 'b': 2, 'c': 3}
# the ** unpack a dict
print sum(**a)
>> 6
def sum(a, b, c):
return a + b + c
a = [1, 2, 3]
# the * unpack list a
print sum(*a)
>> 6
def sum(a, b, c):
return a + b + c
a = {'a': 1, 'b': 2, 'c': 3}
# the ** unpack a dict
print sum(**a)
>> 6
本文标题:2019-08-03 python中 * 的作用
本文链接:https://www.haomeiwen.com/subject/jwajdctx.html
网友评论