码迷,mamicode.com
首页 > 编程语言 > 详细

python笔记常用模块

时间:2016-11-29 21:49:22      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:随机密码   优惠   string   int   case   import   print   生成   大写   

一.python中的string模块

string模块中的ascii_letterss是生成所有的大小写字母a-z,A-Z。dights是生成所有的数字0-9

代码:

  import string

  src_st = string.ascii_letters +string.digits#所有大小写字母+数字

     print(src_st)

应用场景:比如生成一个随机密码,优惠劵,激活码

string.ascii_lowercase‘, ‘====>‘, ‘abcdefghijklmnopqrstuvwxyz‘#所有小写字母的集合
string.ascii_uppercase‘, ‘====>‘, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ‘#所有大写字母的集合

python笔记常用模块

标签:随机密码   优惠   string   int   case   import   print   生成   大写   

原文地址:http://www.cnblogs.com/liuwei55/p/6115134.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!