原文链接:科技爱好者周刊(第 302 期):创业虽然好,不敢推荐了 - 阮一峰的网络日志
英文文章内有不少步骤,尝试下OK,遂直接分享该快捷指令链接,一起分享、学习。
# 命令行调用ocr-text:执行后,可粘贴出识别出的内容
shortcuts run ocr-text -i test.png
---
# python调用orc-text快捷指令,并打印出识别内容
import subprocess
file_path = 'test.png'
byte_string = subprocess.check_output(
f'shortcuts run ocr-text -i "{file_path}"', shell=True
)
# print(byte_string)
# 将字节串解码为UTF-8字符串
decoded_string = byte_string.decode('utf-8')
# 打印解码后的字符串
print(decoded_string)