简单的生成验证码

import random

code = []

for i in range(5):

    if i == random.randint(1,9):#随机生成1-9的数字

        code.append(str(random.randint(1,9)))

    else:

        temp = random.randint(65,90)

        code.append(chr(temp))#随机生成A-Z的字母

print ''.join(code)