반응형
함수가 취하는 매개 변수 이름을 얻는 방법이 있습니까?
def foo(bar, buz):
pass
magical_way(foo) == ["bar", "buz"]
해결 방법
import inspect
def magical_way(f):
return inspect.getargspec(f)[0]
표현 된 요구 사항을 완전히 충족합니다.
참조 페이지 https://stackoverflow.com/questions/3517892
반응형
'파이썬' 카테고리의 다른 글
파이썬 Run Process and Don't Wait (0) | 2020.11.10 |
---|---|
파이썬 ImportError : pydot라는 모듈이 없습니다 (pydot를 가져올 수 없음). (0) | 2020.11.10 |
파이썬 이름으로 Python 메서드 호출 (0) | 2020.11.10 |
파이썬 Add another tuple to a tuple of tuples (0) | 2020.11.09 |
파이썬 Python string.replace ()가 문자를 대체하지 않음 (0) | 2020.11.09 |
댓글