遞歸的定義:函數(shù)自己調(diào)用自己
def func():
print(666)
func()
func() #RecursionError: maximum recursion depth exceeded while calling a Python object
- 遞歸函數(shù)的深度
a = 1
def func(x):
print(x)
x += 1
func(x)
func(a) #996
默認(rèn)996層
設(shè)置層數(shù)
import sys
sys.setrecursionlimit(100000)