1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Python:生成6位随机字符串 字符可以是数字 大写字母 小写字母

Python:生成6位随机字符串 字符可以是数字 大写字母 小写字母

时间:2019-05-10 00:28:47

相关推荐

Python:生成6位随机字符串 字符可以是数字 大写字母 小写字母

#!/usr/bin/env python# coding:UTF-8"""@version: python3.x@author:曹新健@contact: 617349013@@software: PyCharm@file: 生成随机字符串.py@time: /9/10 16:54"""import randomrandomStr= ""for i in range(6):temp = random.randrange(0,3)if temp == 0:ch = chr(random.randrange(ord('A'),ord('Z') + 1))randomStr += chelif temp == 1:ch = chr(random.randrange(ord('a'),ord('z') + 1))randomStr += chelse:ch = str((random.randrange(0,10)))randomStr += chprint(randomStr)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。