time模块与random模块,六位含字母随机验证码

# time模块
# import time
# time.time()#计算这一时刻时间戳 *******
# time.sleep(1)#让cpu休眠一定时间 *******
# time.clock()#计算CPU运行时间,但不包括cpu休眠时间
# time.gmtime()#结构化时间,不过这个时间是英国的,我们主要用下一个时间,这个时间打印出来就是time.struct_time(tm_year=2018, tm_mon=3, tm_mday=20, tm_hour=6, tm_min=25, tm_sec=43, tm_wday=1, tm_yday=79, tm_isdst=0)
# time.localtime()#结构化时间,中国北京时间 ******* time.struct_time(tm_year=2018, tm_mon=3, tm_mday=20, tm_hour=14, tm_min=28, tm_sec=24, tm_wday=1, tm_yday=79, tm_isdst=0)
# print(time.strftime('%Y---%m---%d %H:%M:%S'))#字符串时间2018---03---20 14:41: ********
# time.mktime()#可以把秒转换为时间
# import datetime
# datetime.datetime.now()#打印当前时间



#random 模块 随机数
# import random
# random.random()生成0和1之间的随机浮点数float
# random.choice ('hello')#括号里面必须是可便利数据类型,字符串中间字母的随机出现
# random.shuffle()#洗牌功能,返回一个新的序列
# random.randrange(1,3)#不包含3
#chr()#把数字转换成字母

#六位数随机密码,含字母
import random
def passage():
aoo_passage = ""
for i in range(6):
aoo_passage=aoo_passage+str(random.choice([random.randrange(10),chr(random.randrange(65,92))]))
print(aoo_passage)
return
passage()


原文地址:https://www.cnblogs.com/laoli1020/p/8613293.html