ITPub博客

首页 > 应用开发 > IT综合 > python 随机字符串

python 随机字符串

原创 IT综合 作者:G8bao7 时间:2017-01-04 17:14:25 0 删除 编辑

点击(此处)折叠或打开

  1. #!/usr/bin/env python
  2. # -*- coding:utf-8 -*-

  3. import random
  4. import string

  5. def random_str(size):
  6.     all_char = string.letters + string.digits + string.punctuation
  7.     rchars = [random.choice(all_char) for i in range(size)]
  8.     rstr = "".join(rchars)
  9.     return rstr

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26250550/viewspace-2131899/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: python mysql utf8mb4
请登录后发表评论 登录
全部评论

注册时间:2013-11-04

  • 博文量
    496
  • 访问量
    1258282