有人可以解释为什么rangeinrandom.randint(0, len(messages) - 1)的末尾有负 1 吗?该列表有 9 个值:
import random
messages = ['It is certain',
'It is decidedly so',
'Yes definitely',
'Reply hazy try again',
'Ask again later',
'Concentrate and ask again',
'My reply is no',
'Outlook not so good',
'Very doubtful']
select_number = random.randint(0, len(messages) - 1)
list_select = messages[select_number]
print(list_select)
BIG阳
慕村9548890
红颜莎娜
相关分类