#!/usr/bin/env python #created by Baird from aip import AipOcr def GetCaptchaV(filename): APP_ID = '1X4X8X4X' API_KEY = 'YaVcqamctoYqRHNGAqwVbn97UO' SECRET_KEY = 'C1926rIqGstqPHTUFa6sz481fjDua2pv' client = AipOcr(APP_ID, API_KEY, SECRET_KEY) """ 读取图片 """ def get_file_content(filePath): with open(filePath, 'rb') as fp: return fp.read() image = get_file_content(filename) """ 调用通用文字识别, 图片参数为本地图片 """ ret = client.basicGeneral(image) code = ret["words_result"][0]["words"] print("识别验证码成功===》",code) return code