python随机生成中文验证码的实例代码

python代码

代码如下:

# -*- coding: utf-8 -*-

import image,imagedraw,imagefont

import random

import 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 未分类

发表评论