一、内置函数

chr ------把数字转换为字母

ord-------把字母转换为数字

n = chr(65)

print (n)

m = ord("A")

print(m)

二、随机验证码

import random
li = []
for i in range():
tmpe = random.randrange(,)
c = chr(tmpe)
li.append(c)
aa = "".join(li)
print(aa)

改进版

import random
li = []
for i in range():
r = random.randrange(,)
if r == or r==:
name = random.randrange(,)
li.append(str(name))
else:
tmpe = random.randrange(,)
c = chr(tmpe)
li.append(c)
aa = "".join(li)
print(aa)

python之随机验证码的更多相关文章

  1. Python 生成随机验证码

    Python生成随机验证码  Python生成随机验证码,需要使用PIL模块. 安装: 1 pip3 install pillow 基本使用 1. 创建图片 1 2 3 4 5 6 7 8 9 fro ...

  2. Python生成随机验证码

    Python生成随机验证码,需要使用PIL模块. 安装: pip3 install pillow 基本使用 1.创建图片 from PIL import Image img = Image.new(m ...

  3. Python生成随机验证码,大乐透号码

    实例笔记之生成随机号码 扩展知识 - yield(生成器) 随机生成验证码 示例代码: import random # 导入标准模块中的random if __name__ == '__main__' ...

  4. Python - 生成随机验证码的3种实现方式

    生成6位随机验证码的3种实现方式如下: 1. 简单粗暴型:所有数字和字母都放入字符串: 2. 利用ascii编码的规律,遍历获取字符串和数字的字符串格式: 3. 引用string库. 方法1代码: i ...

  5. python获取随机验证码或者下发激活码

    http://stackoverflow.com/questions/2823316/generate-a-random-letter-in-python >>> import ra ...

  6. django-生成随机验证码

    Python生成随机验证码,需要使用PIL模块. 安装: pip3 install pillow 1   1 pip3 install pillow 基本使用 1.创建图片 from PIL impo ...

  7. python实现图片验证码

    1 验证基础知识1.1 Python生成随机验证码,需要使用PIL模块. # 安装 pip3 install pillow 1.2 创建图片 from PIL import Image img = I ...

  8. django随机验证码

    Python生成随机验证码,需要使用PIL模块. 安装: 1 python3.5 -m pip install pillow 基本使用 1. 创建图片 1 2 3 4 5 6 7 8 9 from P ...

  9. Django_随机验证码

    随机验证码 Python生成随机验证码,需要使用PIL模块. 安装: pip3 install pillow 基本使用 1. 创建图片 from PIL import Image img = Imag ...

随机推荐

  1. python消息队列Queue

    实例1:消息队列Queue,不要将文件命名为"queue.py",否则会报异常"ImportError: cannot import name 'Queue'" ...

  2. HDOJ2586 How far away ?

    一道LCA模板 原题链接 \(LCA\)模板题,不解释. 倍增版 #include<cstdio> #include<cmath> #include<cstring> ...

  3. [Robot Framework] Robot Framework里面的变量怎么知道是在哪里定义的?

    看变量在哪里定义的:Ctrl+Alt+Space

  4. Spring 注解(二)注解工具类 AnnotationUtils 和 AnnotatedElementUtils

    Spring 注解(二)注解工具类 AnnotationUtils 和 AnnotatedElementUtils Spring 系列目录(https://www.cnblogs.com/binary ...

  5. Python之路(第一篇):Python简介和基础

    一.开发简介 1.开发:      开发语言:               高级语言:python.JAVA.PHP.C#..ruby.Go-->字节码                低级语言: ...

  6. tomcat运行监控脚本,自动启动

    参见:http://www.cnblogs.com/coffee_cn/p/8279165.html monitor.sh #!/bin/sh monitorlog=/usr/local/tomcat ...

  7. 【机器学习】从分类问题区别机器学习类型 与 初步介绍无监督学习算法 PAC

    如果要对硬币进行分类,我们对硬币根据不同的尺寸重量来告诉机器它是多少面值的硬币 这种对应的机器学习即使监督学习,那么如果我们不告诉机器这是多少面额的硬币,只有尺寸和重量,这时候让机器进行分类,希望机器 ...

  8. 【WebService】WebService之WSDL文档深入分析(三)

    WSDL概念 WSDL(网络服务描述语言,Web Services Description Language)是一门基于 XML 的语言,用于描述 Web Services 以及如何对它们进行访问. ...

  9. linux下导入导出数据库

    导入导出数据库用mysqldump命令,使用方法与mysql命令类似. 导出 导出sql(包含数据和表结构):mysqldump -uroot -p dbname > dbname.sql 导出 ...

  10. Hibernate 的Configuration、sessionFactory和session和transaction对象解释

    1.Configuration对象: Configuration conf=new Configuration(); conf.configure(); 1.1 到 src下面找到名称hibernat ...