|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 一个账号 于 2020-3-16 18:38 编辑
为什么会 restart 呢?
- Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
- Type "help", "copyright", "credits" or "license()" for more information.
- >>> import sys
- >>> sys.setrecursionlimit(999999)
- >>> def test():
- test()
-
- >>> test()
- ================================ RESTART: Shell ================================
- >>> import sys
- >>> sys.setrecursionlimit(9999999)
- >>> def test():
- test()
-
- >>> test()
- Traceback (most recent call last):
- File "<pyshell#11>", line 1, in <module>
- test()
- File "<pyshell#10>", line 2, in test
- test()
- File "<pyshell#10>", line 2, in test
- test()
- File "<pyshell#10>", line 2, in test
- test()
- [Previous line repeated 7614 more times]
- MemoryError: Stack overflow
- >>> test()
- Traceback (most recent call last):
- File "<pyshell#12>", line 1, in <module>
- test()
- File "<pyshell#10>", line 2, in test
- test()
- File "<pyshell#10>", line 2, in test
- test()
- File "<pyshell#10>", line 2, in test
- test()
- [Previous line repeated 7622 more times]
- MemoryError: Stack overflow
- >>> while True:
- try:
- test()
- except:
- continue
-
- ======================================================================= RESTART: Shell ======================================================================
复制代码
本帖最后由 一个账号 于 2020-3-16 18:38 编辑
第一遍错误:无法复现,应该是和第二次错误原因相同,堆栈溢出。
系统和编译器栈大小默认为1M吧,超过1M就会栈溢出,所以应该只能调低递归深度解决
学识浅薄希望对你有所帮助
|
|