파이썬[Python]: keyword - assert 키워드

내장함수 - assert 키워드(keyword)


/// 설명

디버깅의 편리성을 위해 사용합니다.(표현(expression)이 False 일 경우 오류를 발생시킵니다.)

※ 형식
assert

reference
https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-assert_stmt

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
= True
assert a
 
if a:
    print('Not Error')
else:
    print('means Error')
 
= 1
assert b >= 0
# assert b < 0, 'b >= 0'  # AssertionError
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수