# coding: gbk
import random
import string
import re
def numx():
while 1:
#t=re.compile(r‘[a-z0-9A-Z]‘)
n=‘‘.join(random.sample(string.letters+string.digits,4)).strip(‘/n‘).replace(‘,‘,‘,‘)
print n
xp=re.compile(‘\w+‘, re.I)
rxp=xp.findall(n)[0].upper()
#t1=t.match(n)
#print n.strip(‘-‘)
#n.split("[‘,‘]")
num1=raw_input(‘请输入和上面对应验证:‘)
print ‘num1=%s, rxp=%s‘ % ( num1.upper(), rxp )
#if num1.upper() in rxp or num1.lower()in rxp:
if num1.upper() == rxp:
print ‘验证码正确‘
print‘不区分大小写‘
break
else:
print‘验证码不正确‘
print‘不区分大小写‘
continue
numx()
时间: 2024-10-07 06:08:36