递归在998层就会报错
1 def p(n): 2 print(n) 3 p(n+1) 4 p(1) 5 6 7 # RecursionError: maximum recursion depth exceeded while calling a Python object
解除998层限制
import sys sys.setrecursionlimit(10000) # 可以解除递归998层报错的设置
1 def p(n): 2 print(n) 3 p(n+1) 4 p(1) 5 6 7 # RecursionError: maximum recursion depth exceeded while calling a Python object
import sys sys.setrecursionlimit(10000) # 可以解除递归998层报错的设置