2017-10-13 117 views
-1

我使函数获得函数中的参数个数,但它只给出数字时才给出数字,但发现我真正需要的是通过获取函数名称来获取数字。获取python函数中参数的个数

def a(a, b, c): 
    par = len(locals()) 
    return par 

z = a() 

我需要让z等于3,但它会给出错误。

def a(a, b, c): 
    par = len(locals()) 
    return par 

z = a(1, 2, 3) 

我需要机会得到len没有给出params。

回答