import requests
import requests
import base64
client_id 为官网获取的Api-key, client_secret 为官网获取的SK
def BaiduWordApi(Api_key,Secret_Key,img_url):
host = ‘https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=’ + Api_key + ‘&client_secret=’ + Secret_Key
response = requests.get(host)
access_token = response.json()[‘access_token’]
# print(access_token)
‘’’
通用文字识别
‘’’
request_url = “https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic”
# 二进制方式打开图片文件
f = open(img_url, ‘rb’)
img = base64.b64encode(f.read())
params = {“image”: img}
request_url = request_url + “?access_token=” + access_token
headers = {‘content-type’: ‘application/x-www-form-urlencoded’}
response = requests.post(request_url, data=params, headers=headers)
result = response.json()[‘words_result’]
result_list = []
for i in result:
result_list.append(i.get(‘words’))
return result_list
if name == ‘main’:
j = BaiduWordApi(Api_key=‘’,Secret_Key = '****’,img_url=r’C:\Users***************\test.jpg’)
for i in j:
print(i)
识别结果:
随睿质粒构建,转染,扩增等基因表达相关的分子生物学
技术在科研中的广泛开展,DNA的琼糖凝胶电冰技术由于
其操作简单快速灵敏等优点已成为分离和鉴定生物大分
子(核酸)的1点击查看源网页卡.影响DNA在琼脂糖凝胶
中迁移速率的因素很多,包括DNA分子大小和构象,琼脂糖
浓度,所加电压,电泳缓冲液的离子浓度,嵌人染料一溴化乙
锭(EB的存在等,只有使用最合理的条件组合,才能缩短
实验进程,避免重复操作,获得清晰准确的电泳图谱,达到鉴
定分析质粒片段的目的,我国的科研资源有限,为节省人力,