Home > Backend Development > Python Tutorial > How to identify VAT invoice using one line of Python code?

How to identify VAT invoice using one line of Python code?

WBOY
Release: 2023-04-21 09:04:07
forward
1831 people have browsed it

Identify invoices

Entering invoices is a tedious task. It would be great if it could be automatically identified and entered into the system.

The code to identify invoices is the simplest, requiring only 1 line of code, as shown below

# 导入potencent这个库,下载命令:pip install potencent
import potencent
# 调用增值税识别的功能
potencent.ocr.VatInvoiceOCR(img_path=r'C:\vx_CoderWanFeng\your_img.jpg')
Copy after login

The return result after identification includes the invoice information as follows, covering almost all visible content on the invoice

How to identify VAT invoice using one line of Python code?

How to identify VAT invoice using one line of Python code?

Faced with this returned data, you can of course use the B station that was recommended before: Excel, the number one player in the Python automated office community Automated office course, convert it into Excel, I won’t repeat it here.

Notes

The implementation of this function relies on Tencent Cloud's invoice recognition, so a potencent-config.toml file needs to be configured in the same level directory. The file location and content are as shown below

How to identify VAT invoice using one line of Python code?

[tencent-ai]
TENCENTCLOUD_SECRET_ID = '你的 SecretId'     # 建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参考https://cloud.tencent.com/document/product/598/37140
TENCENTCLOUD_SECRET_KEY = '你的 SecretKey'   # 建议使用子账号密钥,授权遵循最小权限指引,降低使用风险。子账号密钥获取可参考https://cloud.tencent.com/document/product/598/37140
Copy after login

In addition, if you need to customize the configuration file name and location, you can use the configPathparameter

The above is the detailed content of How to identify VAT invoice using one line of Python code?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template