def getAuthCode(): global authCodeRec while 1: im = pic.getPic(authCodeRec.top.x, authCodeRec.top.y, authCodeRec.bottom.x, authCodeRec.bottom.y) authCodeStr = ocr.recognizeAuth(im) print "current auth code " + repr(authCodeStr) # if the authCodeStr contains not number, return to get again. if authCodeStr.isdigit(): return authCodeStr else: time.sleep(0.3) print "recognized auth code " + authCodeStr + "contains abnormal value\n" continue
def getAuthCode(): global authCodeRec while 1: im = pic.getPic(authCodeRec.top.x, authCodeRec.top.y, authCodeRec.bottom.x, authCodeRec.bottom.y) authCodeStr = ocr.recognizeAuth(im) print "current auth code " + repr(authCodeStr) # if the authCodeStr contains not number, return to get again. if authCodeStr.isdigit(): #if the color is no longer read, then strp 1:4. return authCodeStr[1:4] #return authCodeStr else: print "识别到的验证码" + authCodeStr + "包含非法数字\n" continue
def do_2(self, arg): pic.getPic()