How to get method parameter names?

前端 未结 15 2125
眼角桃花
眼角桃花 2020-11-22 09:14

Given the Python function:

def a_method(arg1, arg2):
    pass

How can I extract the number and names of the arguments. I.e., given that I h

15条回答
  •  北海茫月
    2020-11-22 09:50

    I think what you're looking for is the locals method -

    
    In [6]: def test(a, b):print locals()
       ...: 
    
    In [7]: test(1,2)              
    {'a': 1, 'b': 2}
    

提交回复
热议问题