20180502 random函数

#  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函数随机产生,用来匹配!

猜你喜欢

转载自blog.csdn.net/weixin_42020378/article/details/80173231
今日推荐