def foo(n):
print(n)
n += 1
foo(n) if __name__ == '__main__':
foo(1)
打印出998,然后报错
RecursionError: maximum recursion depth exceeded while calling a Python object
调用python对象时超过最大递归深度
设置最大递归层数
import sys
sys.setrecursionlimit(1000)
def foo(n):
print(n)
n += 1
foo(n) if __name__ == '__main__':
foo(1)
打印出998,然后报错
RecursionError: maximum recursion depth exceeded while calling a Python object
调用python对象时超过最大递归深度
设置最大递归层数
import sys
sys.setrecursionlimit(1000)