9. 모듈(module)
모듈 안의 모든 함수 이름 확인 방법 + 함수 설명
만다린망고
2021. 3. 29. 11:20
반응형
함수 목록 출력
모듈 안에 어떤 함수가 있는지 알아야 사용할 수가 있습니다. 모듈 안에 함수 이름을 출력하는 방법은 dir 함수를 사용하는 것입니다.
에를 들어 math 모듈의 함수 목록을 출력해봅시다.
>>> dir(math)
['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'perm', 'pi', 'pow', 'prod', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc']
함수 설명 출력
어떤 함수 인지 알고 싶은 경우에는 help 함수를 사용하면 됩니다.
>>> help(math.sin)
Help on built-in function sin in module math:
sin(x, /)
Return the sine of x (measured in radians)
반응형