随机模块不起作用. ValueError:randrange()(1,1,0)的空范围 [英] Random module not working. ValueError: empty range for randrange() (1,1, 0)

查看:1400
本文介绍了随机模块不起作用. 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)的空范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆