20180502 random函数

xiaoxiao2021-02-28  53

# Author Li import random # print(random.random()) # print(random.randint(1,3))# 包含3 # print(range(3))#取不到3 # print(random.randrange(1,2)) # print(random.uniform(1,100)) checkcode = '' # for i in range(4): # current = random.randint(1,9) # checkcode += str(current) print(checkcode) for i in range(4): current = random.randrange(0,4) if current == i: tmp = chr(random.randint(65,90)) else: tmp = random.randint(0,9) checkcode += str(tmp) print(checkcode)

运行结果:9L23 注:random函数随机产生,用来匹配!
转载请注明原文地址: https://www.6miu.com/read-2626809.html

最新回复(0)