小编Luc*_*cas的帖子

Python - randrange() 的空范围 (0,0, 0) 和 ValueError("randrange() 的空范围 (%d,%d, %d)" % (istart, istop, width))

当我运行这个程序时:(python 3.3.1)

import random
import time
from random import randrange
print(' ')
print('I am thinking of a person...')
time.sleep(1)
print('He or she belongs to this group of people:')
people = 'Alice Elise Jack Jill Ricardo David Jane Sacha Thomas'.split()
loop = 0
while loop != 6:
    group = []
    person = randrange(0, len(people))
    personName = people[person]
    int(person)
    group.append(personName)
    del people[person]
    loop = loop + 1
Run Code Online (Sandbox Code Playgroud)

我有时会收到此错误消息:

Traceback (most recent call last):
  File "C:\Users\user\Python\wsda.py", line 132, in <module>
    person = randrange(0, …
Run Code Online (Sandbox Code Playgroud)

python random module

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

module ×1

python ×1

random ×1