Python sys.setrecursionlimit()

사용 버전: Python 3.7.9

파이썬 sys.setrecursionlimit()을 알아보겠습니다.


재귀 함수를 이용하여 문제를 풀던 중, 런타임 에러를 만납니다.

RecursionError: maximum recursion depth exceeded while calling a Python object

해석해 보면, 재귀 함수 깊이가 최대 호출 가능 수를 초과한다입니다. 파이썬의 기본 제한 값은 1,000입니다.
해결법은 간단합니다.

sys.setrecursionlimit()을 사용하면 됩니다.
괄호 안에는 몇 번을 반복할 수 있게 할지 숫자를 넣어줍니다.




끝.


카테고리: Python, sys

댓글

이 블로그의 인기 게시물

Python urllib.parse.quote()

KiCad 시작하기 4 (기존 회로도 수정 및 추가)

Android Compose Coil library

KiCad 시작하기 1 (회로도 만들기)

Android Notification with Full Screen

iOS Swift callAsFunction

Android Custom IME(Input method editor) 만들기

iOS Error Undefined symbol Testing.Trait

Forensics .pyc 파일 .py로 복구하기

Android Compose automation for getting localized images to use on Play Store app image