Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

python - 使用* args和** kwargs [重复](Use of *args and **kwargs [duplicate])

So I have difficulty with the concept of *args and **kwargs . (所以我很难理解*args**kwargs的概念。)

So far I have learned that: (到目前为止,我已经了解到:)

  • *args = list of arguments - as positional arguments (*args =参数列表-作为位置参数)
  • **kwargs = dictionary - whose keys become separate keyword arguments and the values become values of these arguments. (**kwargs =字典-其键成为单独的关键字参数,而值则成为这些参数的值。)

I don't understand what programming task this would be helpful for. (我不知道这对您有什么帮助。)

Maybe: (也许:)

I think to enter lists and dictionaries as arguments of a function AND at the same time as a wildcard, so I can pass ANY argument? (我认为要输入列表和字典作为函数的参数,并与通配符同时输入,因此我可以传递ANY参数吗?)

Is there a simple example to explain how *args and **kwargs are used? (有一个简单的示例来说明如何使用*args**kwargs吗?)

Also the tutorial I found used just the "*" and a variable name. (我发现的教程也只使用了“ *”和一个变量名。)

Are *args and **kwargs just placeholders or do you use exactly *args and **kwargs in the code? (*args**kwargs只是占位符还是在代码中使用了*args**kwargs ?)

  ask by MacPython translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...