24. docstring
■ docstring이란? 함수에 대한 설명문 help()와 __doc__ 를 이용해 출력할 수 있다. help()는 자세히 출력, __doc__ 은 docstring만 출력 def echo(anything): 'echo returns its input argument' return anything print(echo('I am')) help(echo) # Help on function echo in module __main__: # echo(anything) # echo returns its input argument print(echo.__doc__) # echo returns its input argument
프로그래밍 언어/Python(파이썬)
2023. 10. 17. 08:55