[Python] 纯文本查看 复制代码 def baidu_ket_get():
AppID = open("D:\Python\SDK\key\AppID.txt")
SECRET_KEY = open("D:\Python\SDK\key\Secret_Key.txt")
API_KEY = open("D:\Python\SDK\key\API_Key.txt")
AppID = AppID.read()
SECRET_KEY = SECRET_KEY.read()
API_KEY = API_KEY.read()
# print("{}\n{}\n{}\n".format(AppID,SECRET_KEY,API_KEY))
return AppID,SECRET_KEY,API_KEY
def get_base64(path):
import base64
f = open(path,'rb')
img_base64 =str(base64.b64encode(f.read()), encoding='utf-8')
return img_base64
from aip import AipOcr
import base64
APP_ID = baidu_ket_get()[0]
API_KEY = baidu_ket_get()[2]
SECRET_KEY = baidu_ket_get()[1]
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
# img = open("D:\Python\scan.jpg",'rb')
# img_1 = img.read()
x="D:/Python/scan.jpg"
y=get_base64(x)
z=base64.b64decode(y)
dict = client.basicGeneral(z)
for i in dict:
print(str(i[0]))
以上是我的代码
下面是我的要识别的图片
要识别的图片
识别结果是w1w
为什么会这样??
是我的代码不对吗? |