티스토리 뷰
반응형
파이썬은 설명(Documentation) 문자열(String) 이라고 불리우는, 짧게 줄여서 DocStrings라 불리우는 편리한 기능을 가지고 있습니다. DocString은 만든 프로그램을 알아보기 쉽게 해 주고, 또 후에 프로그램에 대한 설명서를 작성할 때 유용하게 사용될 수 있다.
아래 예제와 같이, DocString은 프로그램이 실행중일 때도 읽어올 수 있다.
def print_max(x, y):
'''Prints the maximum of two numbers.
The two values must be integers.
'''
# convert to integers, if possible
x = int(x)
y = int(y)
if x > y:
print (x, 'is maximum')
else:
print(y, 'is maximum')
print_max(3, 5) # 함수 호출
print(print_max.__doc__)
# 함수 docString 호출 'Prints the maximum of two numbers.
#The two values must be integers.\n\t'
DocString은 일반적으로 첫째줄의 첫문자는 대문자로, 마지막 문자는 마침표로 끝나도록 작성
그리고 두번째 줄은 비워 두고, 세번째 줄부터는 이것이 어떤 기능을 하는지에 대해 상세하게 작성
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- JavaScript
- Spring Boot
- data gird component
- MySQL
- data component
- react
- https://www.tistory.com/auth/logout/
- 파이썬3
- jQuery
- python3
- JPA
- mobx
- Java
- Redux
- 파이썬
- data grid component
- data table component
- Python
- React-router
- Angular
- Spring
- CSS
- JSON
- Router
- 페이스북 로그인
- facebook login
- localStorage
- data component module
- angular router
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함