본문으로 바로가기

python 에러 체크 예제

category Python 2020. 2. 24. 15:53
def rsp(mine, yours):
    allowed = ['가위','바위', '보']
    if mine not in allowed:
        raise ValueError
    if yours not in allowed:
        raise ValueError

try:
    rsp('가위', '바')
except Exception as ex:  # 에러 종류
    print(ex)

 

출처 : https://wayhome25.github.io/python/2017/02/26/py-12-exception/