import random """ @file: 生成随机字符.py @time: 2019年8月13日14:21:41 """ randomStr = "" for i in range(6): temp = random.randrange(0, 3) if temp == 0: ch = chr(random.randrange(ord('A'), ord('Z') + 1)) randomStr += ch elif temp == 1: ch = chr(random.randrange(ord('a'), ord('z') + 1)) randomStr += ch else: ch = str((random.randrange(0, 10))) randomStr += ch print(randomStr)
您阅读这篇文章共花了: