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
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.
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
[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 configPath
parameter
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!