from threading import Timer
import random class Code:
def __init__(self):
self.make_cache() def make_cache(self,interval =15):#生成的验证码保存在cache里,过15s重新生成验证码,更新cache
self.cache = self.make_code()
print(self.cache)
self.t = Timer(interval,self.make_cache)
self.t.start() def make_code(self,n=4):
res = ''
for i in range(n):
s1= str(random.randint(0,9))
s2=chr(random.randint(65,90))
res += random.choice([s1,s2])
return res def check(self):
while True:
code = input('请输入验证码>>:').strip()
if code.upper() == self.cache:
print('验证码正确')
self.t.cancel()
break obj=Code()
obj.check()

最新文章

  1. sqlite的增删改查
  2. javascript获得客户端IP的又一方法
  3. sprinvMVC路径拦截
  4. CLR via C#(09)-扩展方法
  5. java对象equals方法的重写
  6. 数往知来 ADO.NET <八>
  7. 【转】SQL2008清除日志
  8. [二分匹配]URAL1721Two Sides of the Same Coin
  9. GET——token
  10. Oracle table names are case sensitive (normally all uppercase)
  11. 关于css的text-indent首行缩进两个字符和图片缩进的问题
  12. js常用 弹出确认 取消对话框
  13. [模板] tarjan/联通分量/dfs树
  14. Django+Vue打造购物网站(五)
  15. 吴裕雄 python 数据可视化
  16. JavaScript机器学习之KNN算法
  17. ADSL 动态IP拨号VPS 软件配置
  18. PHP实现简单倒计时
  19. leetcode 300最长上升子序列
  20. F4+2 团队项目软件设计方案

热门文章

  1. MOS简介
  2. 找回Xcode7的代码折叠功能
  3. android自己定义渐变进度条
  4. 2016年最值得新手程序猿阅读的书:《增长project师指南》
  5. 网站web.cofig配置用户的权限
  6. ssh服务配置文件---sshd_config详解
  7. LVS的体系结构
  8. Windows窗口程序从创建到关闭产生的消息
  9. VK Cup 2012 Qualification Round 1 E. Phone Talks —— DP
  10. Gym - 101147E E. Jumping —— bfs