六位数随机验证 sms_code.py

时间:2024-01-08 12:12:14
#!/usr/bin/python env
# coding:utf-8 import random def code(num=6):
res = ""
for i in range(num):
# 数字0-9
num1 = str(random.randint(0, 9))
# 大写字母A-Z
# a = chr(random.randint(65, 90))
# 小写字母a-z
# b = chr(random.randint(97, 122))
# res += random.choice([num1, b])
res += random.choice([num1])
return res a = code()
print(a)