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

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

WBOY
WBOYforward
2023-04-21 09:04:071805browse

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')

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

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete