实例介绍Python2随机数列生成器

巴扎黑
巴扎黑 原创
2017-09-05 11:35:53 1181浏览

这篇文章主要介绍了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中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。