def sample(start,end,number):
result=set()
while True:
x=random.randrange(start,end)
if(not (x in result)):
result.add(x)
if(len(result) == number):
return result
使用方法,从0到3610个数中抽取100个数
x=sample(0,3610,100)
从0到3610中抽取100个数的方法
博客介绍了从0到3610个数中抽取100个数的使用方法,给出了代码x=sample(0,3610,100)。
1万+

被折叠的 条评论
为什么被折叠?



