如果是,那为什么sys.setrecursionlimit(999999)后仍然是这个报错?
m=999999
import sys
sys.setrecursionlimit(999999)
def calculate():
global m
while str(m)[-1:1:-1]==str(m)[2::1]:
while str(m-1)[1::1]==str(m-1)[-1:0:-1]:
while str(m-2)[1:-1]==str(m-2)[-2:0:-1]:
while str(m-3)!=str(m-3)[::-1]:
m=m-1
else:
return m
print(m)
else:
m=m-1
else:
m=m-1
calculate()
calculate()
报错信息:
Traceback (most recent call last):
File "C:\Users\jyz_1\Desktop\mile.py", line 22, in
calculate()
File "C:\Users\jyz_1\Desktop\mile.py", line 21, in calculate
calculate()
File "C:\Users\jyz_1\Desktop\mile.py", line 21, in calculate
calculate()
File "C:\Users\jyz_1\Desktop\mile.py", line 21, in calculate
calculate()
[Previous line repeated 6779 more times]
File "C:\Users\jyz_1\Desktop\mile.py", line 6, in calculate
while str(m)[-1:1:-1]==str(m)[2::1]:
MemoryError: stack overflow