在python函数中获取参数名称的列表

在python函数中获取参数名称的列表,第1张

在python函数获取参数名称的列表

好吧,我们实际上不需要

inspect
这里。

>>> func = lambda x, y: (x, y)>>> >>> func.__pre__.co_argcount2>>> func.__pre__.co_varnames('x', 'y')>>>>>> def func2(x,y=3):...  print(func2.__pre__.co_varnames)...  pass # Other things... >>> func2(3,3)('x', 'y')>>> >>> func2.__defaults__(3,)

对于Python 2.5及更高版本,请使用

func_pre
代替
__pre__
func_defaults
代替
__defaults__



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5620704.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存