首页 > 编程语言 > 详细

python 生产随机字符

时间:2016-03-29 19:25:40      阅读:142      评论:0      收藏:0      [点我收藏+]
  1 from random import Random
  2 
  3 def random_str(randomlength):
  4     str = ‘‘
  5     chars = 0123456789-.qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM
  6     length = len(chars) - 1
  7     random = Random()
  8     for i in range(randomlength):
  9         str+=chars[random.randint(0,length)]
 10     print str
 11     return str
 12 random_str(randomlength=255)

 

python 生产随机字符

原文:http://www.cnblogs.com/wangyanhui-joel/p/5334030.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!