Suppose there is such a piece of code:
>>> def add (x,y):
... return x + y
...
>>> c = add.__code__
For Python3, we can get the keyword parameter to be 0 through c.co_kwonlyargcount
. For Python2, how to implement equivalent writing and get the corresponding keyword parameter? quantity.
淡淡烟草味2017-05-24 11:37:02
The number of parameters obtained by python2 and python3 is different:
def add(x, y):
return x + y
python2:
c = add.func_code
c.co_argcount
python3:
c = add.__code__
c.co_argcount