本文摘自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中lambda函数的用法介绍(附示例)
Python官网怎么下载Python
Python中lambda表达式的简单介绍(附示例)
三篇文章帮你搞定怎样进行mysql数据库学习之安装sql数据库
简单介绍Python编程中的字符串编码问题
用Python读写excel文档
Python2和Python3哪个版本新
Python3中* 和 ** 运算符的用法是什么
Python和matlab哪个难
Python全栈好找工作吗
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 实例介绍Python2随机数列生成器