Skip to Content
Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)
book

Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)

by 우정은, 폴 배리
December 2017
Beginner
624 pages
15h 38m
Korean
Hanbit Media, Inc.
Content preview from Head First Python, 개정판 : 스스로 질문하며 답을 찾는 파이썬 학습서(Python 3)
지금 여기예요
4
463
예외 처리
에러가 쉽게 발생할 수 있는 코드는 항상
실행해보세요
코드에 문제가 발생하면 파이썬은 런타임 예외(
exception
)를 일으킵니다. 예외란
인터프리터가 발생시키는 제어된 프로그램 크래시입니다.
1
번과
4
번 문제에서 살펴봤듯이 다양한 상황에서 예외가 발생할 수 있습니다.
인터프리터는 여러 내장 예외 유형을 제공하는데
4
번 문제의
RuntimeError
도 그중
하나입니다. 내장 예외 유형 외에도 직접 커스텀 예외를 정의할 수 있습니다. 예를 들어
1
번 문제의
InterfaceError
MySQL
Connector
모듈에서 정의한 예외입니다.
런타임 예외를 찾아 복원하려면 런타임에 에러가 발생했을 때 이를 관리할 수 있도록
파이썬에서 제공하는
try
문을 이용합니다.
런타임에 문제를 발생시킬 수 있는 코드를 이용해
try
가 어떤 역할을 하는지 확인합시다.
다음 코드는 겉보기에는 아무 문제가 없어 보이지만 런타임에 잠재적인 문제를 일으킵니다.
모든 내장 예외 목록은
https://docs.
python.org/3/library/
exceptions.html
에서
확인할 수 있습니다.
이상할 것도 없고 놀라울 것도 없는 평범한
코드입니다. 지정한 파일을 열고 데이터를
얻어서 화면에 출력하는 프로그램이에요.
이 세 행은 아무 문
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

NGINX 쿡북 : 112가지 레시피로 배우는 고성능 부하분산, 보안, 서버 배포와 관리

NGINX 쿡북 : 112가지 레시피로 배우는 고성능 부하분산, 보안, 서버 배포와 관리

노승현, 데릭 디용기
몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지

몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지

김인범, 크리스티나 초도로우, 섀넌 브래드쇼, 오언 브라질

Publisher Resources

ISBN: 9791162240281