在override __init__()时,经常会有*args和**kwargs,*args代表接受任意实参, **kwargs代表接受任意keyword参数。
Putting *args and/or **kwargs as the last items in your function definition’s argument list allows that function to accept an arbitrary number of anonymous and/or keyword arguments.
It’s probably more commonly used in object-oriented programming, when you’re overriding a function, and want to call the original function with whatever arguments the user passes in.
You don’t actually have to call them args and kwargs, that’s just a convention. It’s the * and ** that do the magic.
阅读(1109) | 评论(0) | 转发(0) |