以下代码适用于 txt 文件,但不适用于 pdf 文件。
import textract
text = textract.process(r'C:\Users\Python_files\accounts.txt')
但是,我似乎无法弄清楚以下代码片段中的问题所在:
import textract
path = r'C:\Users\Python_files\accounts.pdf'
text = textract.process(path)
以上代码导致以下错误:
ShellError: The command `pdftotext C:\Users\Python_files\accounts.pdf -` failed with exit code 127
------------- stdout -------------
------------- stderr -------------