[ Python ]
8. 예외처리 (Python Exception Handling)
2024-07-12 15:58:19
try 문 try(오류 검출)-except(예외처리)-else-finally는 오류를 처리하는 방법입니다.try-excepttry진행 중 error가 생기면 try 문을 중지하고 except를 진행합니다. 이후 작성된 code를 실행시킵니다.try: print("try") print(a) # errorexcept: print("except")print("Progress")더보기tryexceptProgressexcept에 오류명을 적어서 특정 오류만 검출할 수 있습니다.여러 개의 except를 만들어서 사용가능합니다.먼저 검출된 error의 except만 실핻됩니다.as는 특정 객체를 변수에 할당하는 명령어입니다.try: print("try") print(a) # error ..