Python中默认的最大递归深度是989,当尝试递归第990时便出现递归深度超限的错误:

RuntimeError: maximum recursion depth exceeded in comparison

简单方法是使用阶乘重现:

 #!/usr/bin/env Python

 def factorial(n):
if n == 0 or n == 1:
return 1
else:
return(n * factorial(n - 1))

>>> factorial(989)

...

>>>factorial(990)

...

RuntimeError: maximum recursion depth exceeded in comparison

解决方案:

可以手动设置递归调用深度:

>>> import sys
>>> sys.setrecursionlimit(10000000)

Python递归报错:RuntimeError: maximum recursion depth exceeded in comparison的更多相关文章

  1. python递归深度报错--RuntimeError: maximum recursion depth exceeded

    当你的程序递归的次数超过999次的时候,就会引发RuntimeError: maximum recursion depth exceeded. 解决方法两个: 1.增加系统的递归调用的次数: impo ...

  2. scrapy RuntimeError: maximum recursion depth exceeded while calling a Python object 超出python最大递归数异常

    2019-10-21 19:01:00 [scrapy.core.engine] INFO: Spider opened2019-10-21 19:01:00 [scrapy.extensions.l ...

  3. 记 suds 模块循环依赖的坑-RuntimeError: maximum recursion depth exceeded

    下面是soa接口调用的核心代码 #! /usr/bin/python # coding:utf-8 from suds.client import Clientdef SoaRequest(wsdl, ...

  4. python --RecursionError: maximum recursion depth exceeded in comparison

    在学习汉娜塔的时候,遇到一个error RecursionError: maximum recursion depth exceeded in comparison 经过百度,百度的方法: 加上: i ...

  5. 函数递归时,递归次数到900多时,就是抛出异常exception RuntimeError('maximum recursion depth exceeded',)

    import subprocess import multiprocessing import urllib import sys import os import pymongo import si ...

  6. python RecursionError: maximum recursion depth exceeded in comparison错误

    处理快速排序,递归深度可能非常大,而系统默认的深度可能没有这么大 需要设置最大递归深度 import sys sys.setrecursionlimit(100000) # 这个值的大小取决你自己,最 ...

  7. python maximum recursion depth exceeded 处理办法

    1.在执行命令 pyinstaller -F D:\py\programe\banksystem.py打包生成.exe文件时报错:python maximum recursion depth exce ...

  8. Odoo8查询产品时提示"maximum recursion depth exceeded while calling a Python object"

    今天在生产系统中查询产品时,莫名提示错误:maximum recursion depth exceeded while calling a Python object,根据错误日志提示,发现在查询产品 ...

  9. 爬豆瓣影评,记下解决maximum recursion depth exceeded in cmp

    #主要是爬取后给别人做自然语言分析,没其他意思. #coding=utf8 import requests,re from lxml import etree import sys reload(sy ...

随机推荐

  1. idea转eclipse 设置注意。

    下载适合的eclipse

  2. HttpClientUtil工具类,待更新

    package com.igs.webShop.web.util; import org.apache.http.HttpEntity;import org.apache.http.HttpRespo ...

  3. swift基础:第一部分:基本数据类型及结构

    首先谈点开心的:今天是周二,广州的天气格外明朗,早上上班的心情也不一样,最值得高兴事,很快到五一劳动节了,说到劳动节,放假是吧.你懂的.再来谈谈我上周的工作总结,上周可以说是黑轮压城城欲摧,甲光向日金 ...

  4. eclipse for java developer和eclipse for java ee developer的区别

    eclipse是基于插件机制的软件,插件本身是不能启动和操作的,它们需要一个环境,eclipse使用osgi r4规范实现了这个环境. osgi是java动态模块化的规范,该规范不光要让java程序模 ...

  5. dll 日志文件 放在同一个目录。

    string strPath = "log.txt"; 如果日志问价跟dll文件放在一起,直接这么些就可以了.

  6. 机器学习实战4:Adaboost提升:病马实例+非均衡分类问题

    Adaboost提升算法是机器学习中很好用的两个算法之一,另一个是SVM支持向量机:机器学习面试中也会经常提问到Adaboost的一些原理:另外本文还介绍了一下非平衡分类问题的解决方案,这个问题在面试 ...

  7. Good Bye 2015 D. New Year and Ancient Prophecy

    D. New Year and Ancient Prophecy time limit per test 2.5 seconds memory limit per test 512 megabytes ...

  8. 数据采集实践学习二(C#)

    前一篇文章写到我获取数据的方式不是通过分析HTML获得,而是通过分析请求链接,然后模拟请求方法获取数据,这只是一种方法.而且是在我通过分析HTML获取不到的情况下,曲线救国,参考别人文章实现的.很高兴 ...

  9. request_irq() | 注册中断服务函数【转】

    本文转载自:http://blog.csdn.net/wealoong/article/details/7566546#t0 参考  : ARM Linux 中断机制分析.pdf linux-2.6. ...

  10. HTML初步入门

    标签元素 标签介绍 html元素包括一个或一对标签定义的包含范围.而标签就是由两个字符串"<"和">"号组成,标签包括开始标签"<& ...