Equivalent writing of code.co_kwonlyargcount in Python2
天蓬老师
天蓬老师 2017-05-24 11:35:02
0
2
649

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.

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
滿天的星座

https://docs.python.org/2/lib...

淡淡烟草味

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!