python函数调用参数问题

def example(a, b, c=100):
… a = 1 # notice here I am assigning ‘a’
… b = 2 # and here the value of ‘b’ is being overwritten
… # The value of c is set to 100 by default
… print(a,b,c)

example(4,5) # Here I am passing in 4 for a, and 5 for b
(1, 2, 100) # but notice its not taking any effect

example(9,10,11) # Here I am passing in a value for c
(1, 2, 11)

可以进一步参考这篇博文,原文链接

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页