赞
踩
# 随机产生4位验证码
# 定义一个函数
def ran():
# 产生随机数内容
str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
# 定义空字符串
code = ''
for i in range(4):
# 使用for循环产生验证码--执行4次
str1 = random.randint(1, len(str) - 1)
code += str[str1]
return code
# 调用函数,也可以赋值在打印
print(ran())
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。