"""
随机生成四位数验证码
"""
import random
checkcode = ''
for i in range(4):
a = random.randint(0, 9) # 生成一个0~9随机数
b = str(a) # 把生成的随机数转变成str字符串类型,以便下一行进行拼接操作
checkcode = checkcode + b
print(checkcode)
06-23
503
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-11
6151
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-17
398
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)