有没有办法找出 python 函数的位置参数的名称?
def foo(arg1, arg2):
pass
f=foo
# How do I find out want the 1st argument to f is called? I want 'arg1' as an answer
最佳答案
函数inspect.getargspec()
在 Python 2 中做你需要的。
在 Python 3 中,这已被弃用,您应该改为使用 signature
.
关于python - 通过内省(introspection)查找位置参数的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6255284/