在 Windows 上使用带有空格键的字符白名单是不允许的

作者: art0007i创建于 2025年6月23日更新于 2025年8月7日

我希望我没有忽略任何明显的问题,但从我的实验来看,在 Windows 上使用包含空格的字符白名单似乎是不可能的。 我尝试了: pytesseract.image_to_string(img, config=conf) 其中 conf 为 "--psm 6 -c tessedit_char_whitelist=' 0123456789'" "--psm 6 -c tessedit_char_whitelist=" 0123456789" "--psm 6 -c tessedit_char_whitelist=\' 0123456789 \'" "--psm 6 -c tessedit_char_whitelist=\' 0123456789 \'" 这些都不起作用,似乎底层代码在 Windows 上运行 `shlex.split`, 并将 `posix=False`。 这使得它总是以空格为分隔符,而忽略引号,我编辑了 pytesseract 的源代码,在 Windows 上将 `posix=True`, 这解决了我的问题。

内容来源: madmaze/pytesseract