Crossin的编程教室
标题:
获取随机数
[打印本页]
作者:
sharkrain
时间:
2017-7-16 13:00
标题:
获取随机数
from
random
import
randint
def
get_rand(end, step):
if
step > end
or
step <
1
:
raise
AttributeError
(
"1<step<end,please check."
)
else
:
rand = []
while
len
(rand) < step:
rand.append(randint(
1
, end))
return
rand
if
__name__ ==
"__main__"
:
print
(get_rand(
10
,
5
))
欢迎光临 Crossin的编程教室 (https://bbs.crossincode.com/)
Powered by Discuz! X2.5