What is the difference between arguments and parameters?

来源:互联网 发布:免费流量控制软件 编辑:程序博客网 时间:2024/05/21 13:59

https://docs.python.org/3/faq/programming.html#what-is-the-difference-between-arguments-and-parameters

Parameters are defined by the names that appear in a function definition, whereas arguments are the values actually passed to a function when calling it. Parameters define what types of arguments a function can accept. For example, given the function definition:

def func(foo, bar=None, **kwargs):    pass

foobar and kwargs are parameters of func. However, when calling func, for example:

func(42, bar=314, extra=somevar)

the values 42314, and somevar are arguments.


简而言之:arguments是实参,parameters是形参。阅读英文文档有点帮助。



阅读全文
0 0