Software Development/Python

Python traceback -오류를 역추적 하기

루ㅌ 2020. 6. 24. 20:36

traceback 이란 오류를 발생시킨 함수 호출을 역추적한 내용입이다.

스택 트레이스를 인쇄할 때 파이썬 인터프리터의 동작을 정확하게 모방합니다

 

import traceback


def run():
    return 1/0

def main():
    try:
        run()
    except:
        print(traceback.format_exc())

while True:
    main()