#! /usr/bin/env python3
import random checkcode = ""
## 全部为数字的验证码
# for i in range(4):
# current = random.randrange(0,6)
# checkcode += str(current)
# print(checkcode) ## 有数字、字母的验证码
for i in range(6):
current = random.randrange(0, 4) ## 类似于[start, end)
if current == i:
tmp = chr(random.randint(65, 90)) ##等价于 random.randrange(65, 91)
else:
tmp = random.randint(0, 9)
checkcode += str(tmp)
print(checkcode)
05-23 18:12