多语言展示
当前在线:583今日阅读:155今日分享:35

python 验证码库 captcha的使用问题解决

学习Python库,遇见问题及时解决。
工具/原料
1

GitHub

2

python开发环境

方法/步骤
1

先附上库的GitHub地址:https://github.com/mbi/django-simple-captcha看下帮助文档,如果把这个库应用到我们的项目中1.Download django-simple-captcha using pip by running: pip install django-simple-captcha 首先pip安装这个库2.. Add captcha to the INSTALLEDAPPS in your settings.py 然后在settings.py-->INSTALLEDAPPS

2

3..Run python manage.py syncdb (or python manage.py migrate if you are managing database migrations via South) to create the required database tables执行makemigrations 命令 以及 migrate,生成对应的数据库文件,可以查看下数据库

3

4.Add an entry to your urls.py:配置url

4

这样我们准备工作就做好了,注册用到了这个验证码问题,具体的怎么实现的显示可以移步到登录注册看,当我们把所有代码逻辑写出执行,发现并没有出现预想的结果。而是。。。。。

5

然后一脸懵逼的 F12看了下竟然 。。。。

6

windows系统,使用PIL库的ImageFont.truetype()方法时,报错:The _imagingft C module is not installed说明自己电脑里安装的PIL库缺少一个freetype的库文件,我也手动安装了这个库,出现了_imagingft.pyd,但是import _imagingft时报错说DLL无法加载。现在已解决了这个问题,解决方法:1、卸载原来版本的PILpip uninstall pil2、重新安装一个已经包含freetype库的PIL安装包,可以从该地址下载,并安装。

注意事项

开发一定要耐心的调试

推荐信息