#! /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)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-07-06
  • 2022-12-23
  • 2021-10-07
  • 2021-07-08
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2022-12-23
  • 2021-12-07
  • 2021-06-11
  • 2021-07-13
  • 2021-11-20
  • 2018-12-31
相关资源
相似解决方案