这篇文章主要介绍了python2随机数列生成器,结合简单实例形式分析了python基于random模块操作随机数的相关实现技巧,需要的朋友可以参考下
本文实例讲述了Python2随机数列生成器。分享给大家供大家参考,具体如下:
#filename:randNumber.py
import random
while True:
try:
row=int(raw_input('Enter the rows:'))
cols=int(raw_input('then Enter the cols:'))
minNum=int(raw_input('then Enter the minNumber:'))
maxNum=int(raw_input('then Enter the maxNumber:'))
r=0
while r<row:
line=''
c=0
while c<cols:
s=random.randint(minNum,maxNum)
line+=str(s)
line+=' '
c+=1
r+=1
print(line)
except ValueError as err:
print err以上就是实例介绍Python2随机数列生成器的详细内容,更多请关注php中文网其它相关文章!
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号