Show me the code之Python练习册 Q10 生成验证码
来源:互联网 发布:浙江濮院淘宝供货地 编辑:程序博客网 时间:2024/06/11 11:40
""" 问题:使用 Python 生成类似于下图中的字母验证码图片"""from PIL import Image, ImageFont, ImageDrawimport random# 图片宽度width = 100# 图片高度height = 40def getcodeimg(): choiceCode = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C','D','E'] # 随机生成10个数字 code = [random.choice(choiceCode) for i in range(4)] print(' '.join(code)) image = Image.new('RGB', (width, height)) font = ImageFont.truetype('verdanaz.ttf', 20) draw = ImageDraw.Draw(image) draw.text((0, 0), ' '.join(code), font=font, fill='red') image.save('d://adfaf.png')if __name__ == '__main__': getcodeimg()
0 0
- Show me the code之Python练习册 Q10 生成验证码
- Show me the code之Python练习册 Q4~7
- Show me the code之Python练习册Q23-留言板
- Python Show-Me-the-Code 第 0010 题 生成验证码图片
- Show me the code之Python练习册 Q1~3 优惠券
- Show me the code之Python练习册 Q8~9 html解析
- Show me the code之Python练习册 Q11~12 关键词过滤
- Show me the code之Python练习册 Q13 获取网络图片
- Show me the code之Python练习册 Q14~16 excel操作
- Show me the code之Python练习册 Q17~19 xml操作
- python 之 Counter ---show me the code 0004
- python之 heapq -- show me the code 0006
- python之os -- show me the code 0005
- Python Show-Me-the-Code 第 0001 题 生成激活码
- python PIL --show me the code 0000
- python show-me-the-code 第0004
- python 操作 redis --show me the code 0003
- Python Show-Me-the-Code 第 0002 题 MySQL操作
- 操作系统项目(一)安装as86 ld86
- iOS开发UI篇—iOS开发中三种简单的动画设置
- C/C++基础知识02---数据结构
- Struts2配置文件
- xml文件轉化為datatable
- Show me the code之Python练习册 Q10 生成验证码
- Oracle 数据泵详解
- Action配置
- 顺序串的实现(插入、截取、匹配)
- PHP原生态记录Log函数
- mfc 单文档显示当前系统时间
- 分数修改
- 使用afinal框架实现简单的下载
- 八皇后问题