python生成随机验证码(中文验证码)示例

代码如下:

# -*- coding: utf-8 -*-import image,imagedraw,imagefontimport randomimport math, string

class randomchar(): “””用于随机生成汉字””” @staticmethod def unicode(): val = random.randint(0x4e00, 0x9fbf) return unichr(val)

@staticmethod def gb2312(): head = random.randint(0xb0, 0xcf) body = random.randint(0xa, 0xf) tail = random.randint(0, 0xf) val = ( head

Posted in 未分类

发表评论