- 测试 python 默认允许的栈的深度,执行后输出到 999 后报 RuntimeError 异常,说明栈深默认为 999
def foo(n): | |
print(n) | |
n += 1 | |
foo(n) | |
if __name__ == '__main__': | |
foo(1) |
- 解除改限制,如设置递归限制为 1200,此时栈深 1199
def foo(n): | |
print(n) | |
n += 1 | |
foo(n) | |
if __name__ == '__main__': | |
import sys | |
sys.setrecursionlimit(1200) | |
foo(1) |