CAPTCHA_NOISE_FUNCTIONS = ( 'captcha.helpers.noise_null',# 设置样式
'captcha.helpers.noise_arcs',# 设置干扰线
#'captcha.helpers.noise_arcs_random', # 设置自定义的干扰线
#'captcha.helpers.noise_dots',# 设置干扰点
)

官方写的方法干扰线是固定的

CAPTCHA_NOISE_FUNCTIONS = ( 'captcha.helpers.noise_null',# 设置样式
# 'captcha.helpers.noise_arcs',# 设置干扰线
'captcha.helpers.noise_arcs_random', # 设置自定义的干扰线
#'captcha.helpers.noise_dots',# 设置干扰点
)

然后找到captcha/helpers.py  在这个文件添加下面的函数

def noise_arcs_random(draw, image):
size = image.size
draw.arc([-20, -20, random.randint(size[0]/1.5, size[0]), random.randint(15, 25)], 0, 295, fill=settings.CAPTCHA_FOREGROUND_COLOR)
draw.line([-20, random.randint(5, size[1]), random.randint(size[0]/1.5, size[0]), random.randint(5, size[1])], fill=settings.CAPTCHA_FOREGROUND_COLOR)
draw.line([-20, random.randint(5, size[1]), random.randint(size[0]/1.5, size[0]), random.randint(5, size[1])], fill=settings.CAPTCHA_FOREGROUND_COLOR)
return draw

最新文章

  1. JAVA编程思想(第四版)学习笔记----4.8 switch(知识点已更新)
  2. Codeforces525E Anya and Cubes(双向搜索)
  3. 修复 Java 内存模型,第 1 部分——Brian Goetz
  4. six month dormancy test
  5. 通通制作Html5小游戏——第二弹(仿flappy bird像素鸟)
  6. ASP.NET页面生存周期
  7. Ajax_2
  8. 2734: [HNOI2012]集合选数 - BZOJ
  9. phpcms首页商机的调用,多种方式
  10. python计算md5值
  11. 实现table中checkbox复选框、以及判断checked是否被选中、js操作checkedbox选中
  12. mytest 截图
  13. 【算法】RMQ LCA 讲课杂记
  14. winform listview用法
  15. rhel6.4 安装 mysql-5.6
  16. 面向对象(__item__)
  17. Code Pages
  18. LOJ2538 PKUWC2018 Slay the Spire DP
  19. CF1101D GCD Counting(数学,树的直径)
  20. win下使用VM虚拟机安装Linux系统

热门文章

  1. arch安装问题总结
  2. 一个关于document.write()的问题
  3. Callback, Promise和Async/Await的对比
  4. Today is the first day of the rest of your life.
  5. MySQL-数据类型及选择
  6. Nginx+Keepalived双主轮询负载均衡
  7. HDU 1114 Piggy-Bank 猪仔储钱罐(完全背包)
  8. POJ 1703 Find them, Catch them(并查集,等价关系)
  9. NOIP2018赛前停课集训记(10.24~11.08)
  10. Problem L: 搜索基础之马走日