本文摘自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运维学什么
numpy实现合并多维矩阵、list的扩展方法
如何用Python检查密码的有效性
Python输出语句如何写
Python中如何搭建虚拟环境?Python搭建虚拟环境的步骤
Python找工作难吗
Python中注释一般为什么颜色
r在Python中表示什么意思
Python中的mkdir方法怎么用
pandas技巧之 详解dataframe中的apply与applymap方法
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » 实例介绍Python2随机数列生成器