小编Mik*_*ike的帖子

如何生成一些都是奇数的随机数

import random

myfile = open('numbers.txt', 'w')
file_size = random.randint(4,7)

for count in range(file_size):
    numbers = random.randint(5,19)
    myfile.write(str(numbers) + '\n')

myfile.close()
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止所拥有的,但我需要数字是所有赔率和“file_size”告诉代码的正确赔率。每个整数必须是随机的,介于 5 和 19 之间。

python python-3.x

4
推荐指数
1
解决办法
8479
查看次数

标签 统计

python ×1

python-3.x ×1