开发者社区 > 视觉智能 > 文字识别 > 正文

OCR有表格识别的python3 代码吗?

OCR有表格识别的python3 代码吗?

展开
收起
鸡蛋灌饼儿 2023-02-07 11:56:28 260 0
1 条回答
写回答
取消 提交回答
  • # -*- coding: utf-8 -*-
    # This file is auto-generated, don't edit it. Thanks.
    from __future__ import unicode_literals
    
    import sys
    
    from alibabacloud_ocr_api20210707.client import Client as ocr_api20210707Client
    from alibabacloud_tea_openapi import models as open_api_models
    from alibabacloud_ocr_api20210707 import models as ocr_api_20210707_models
    from alibabacloud_tea_util import models as util_models
    from alibabacloud_tea_util.client import Client as UtilClient
    
    
    class Sample(object):
        def __init__(self):
            pass
    
        @staticmethod
        def create_client(access_key_id, access_key_secret):
            """
            使用AK&SK初始化账号Client
    
            @type access_key_id: str
            @param access_key_id:
    
            @type access_key_secret: str
            @param access_key_secret:
    
            @return: Client
            @throws Exception
            """
            config = open_api_models.Config(
                # 必填,您的 AccessKey ID,
                access_key_id=access_key_id,
                # 必填,您的 AccessKey Secret,
                access_key_secret=access_key_secret
            )
            # 访问的域名
            config.endpoint = 'ocr-api.cn-hangzhou.aliyuncs.com'
            return ocr_api20210707Client(config)
    
        @staticmethod
        def main(args):
            # 工程代码泄露可能会导致AccessKey泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378659.html
            client = Sample.create_client('accessKeyId', 'accessKeySecret')
            recognize_table_ocr_request = ocr_api_20210707_models.RecognizeTableOcrRequest()
            runtime = util_models.RuntimeOptions()
            try:
                # 复制代码运行请自行打印 API 的返回值
                client.recognize_table_ocr_with_options(recognize_table_ocr_request, runtime)
            except Exception as error:
                # 如有需要,请打印 error
                UtilClient.assert_as_string(error.message)
    
    
    if __name__ == '__main__':
        Sample.main(sys.argv[1:])
    
    
    2023-02-07 23:42:53
    赞同 展开评论 打赏

文字识别技术可以灵活应用于证件文字识别、发票文字识别、文档识别与整理等行业场景,满足认证、鉴权、票据流转审核等业务需求。

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载