python 生产随机字符

  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)

 

posted @ 2016-03-29 18:38  Joelwang  阅读(208)  评论(0编辑  收藏  举报