本文摘自php中文网,作者巴扎黑,侵删。
这篇文章主要介绍了Python2随机数列生成器,结合简单实例形式分析了Python基于random模块操作随机数的相关实现技巧,需要的朋友可以参考下本文实例讲述了Python2随机数列生成器。分享给大家供大家参考,具体如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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随机数列生成器的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Python的换行符是什么?
Python爬虫---汽车之家字体反爬
Python中异常和错误的区别
什么是Python?你应该学习和使用它的13个理由
Python如何去除字符串中不想要的字符
Python拆分具有多个分隔符的字符串
Python如何做一个登录注册界面
Python中关于list()列表的具体分析
Python中的def是什么意思
Python构建xml树结构的实例教程
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 实例介绍Python2随机数列生成器