Random module not working. ValueError: empty range for randrange() (1,1, 0)(随机模块不工作.ValueError:randrange() 的空范围 (1,1, 0))
问题描述
在 Python 2.7.1 中,我导入随机模块.但是,当我调用 randint() 时,出现错误:
In Python 2.7.1, I import the random module. when I call randint() however, I get the error:
ValueError: empty range for randrange() (1,1, 0)
此错误是由 random.py 模块本身的错误引起的.我不知道如何修复它,重新安装python帮助也不知道.我无法更改版本.
This error is caused by an error in the random.py module itself. I don't know how to fix it, not does reinstalling python help. I can't change versions.
谁能给我一个工作模块的代码或告诉我该怎么做?
can someone please give me code for a working module or tell me what to do?
推荐答案
你这样调用randint:
You called randint like this:
randint(1,0)
这告诉 randint 返回一个从 1 到 0 的值.从 1 到 0 的数字范围肯定是一个空范围.因此错误:
That tells randint to return a value starting as 1 and ending at 0. The range of numbers from 1 to zero is as you surely realize an empty range. Hence the error:
empty range for randrange()
这篇关于随机模块不工作.ValueError:randrange() 的空范围 (1,1, 0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:随机模块不工作.ValueError:randrange() 的空范围 (1,1, 0)


基础教程推荐
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 筛选NumPy数组 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01