def hello(*params, base=10):
print(params)
print(base)
hello(1, 2, 3, 4, base=5)
# ===> 1, 2, 3, 4
# ===> 5
hello(1, 2, 3, 4, 5)
# ===> 1, 2, 3, 4, 5
# ===> 10
def hello(*params, base=10):
print(params)
print(base)
hello(1, 2, 3, 4, base=5)
# ===> 1, 2, 3, 4
# ===> 5
hello(1, 2, 3, 4, 5)
# ===> 1, 2, 3, 4, 5
# ===> 10
本文标题:[python] 如何区分收集参数和默认参数?
本文链接:https://www.haomeiwen.com/subject/gkgsottx.html
网友评论