python - Django 中的 Kwargs

标签 python django

Kwarg 是什么!??

我一直在学习 django 的教程,试图学习这门语言,但我偶然发现了这一点。

如果有人可以发布/指出一个简单的例子来帮助理解为什么以及如何使用它,我将不胜感激。

最佳答案

基于 Keyword arguments' documentation @Ignacio Vazquez-Abrams

指出

**kwargs allows you to handle named arguments that you have not defined in advance.

In a function call, keyword arguments must follow positional arguments.

All the keyword arguments passed must match one of the arguments accepted by the function (e.g. actor is not a valid argument for the parrot function), and their order is not important.

关于python - Django 中的 Kwargs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5255913/

相关文章:

python - 如何在Python中创建带有负索引/输入的查找表?

python - pandas分布表按所有列分组

python - 无法运行本地 Celery Worker,没有名为 myapp 的模块

python - Django Structlog 未将日志消息打印或写入控制台或文件

python - Django - make_random_password 方法,它真的是随机的吗?

python - 错误 : didn't return an HttpResponse object. 它返回 None

python - 为最大日期和符号过滤 pandas 数据框

python - 当有多个 Boost.Python 模块时,Pickling 公开的类

javascript - cherrypy/jquery CORS 问题

python - 在 Django 中生成独特的 slug