如何阅读保存在本地驱动器上的pdf文档?找不到文件或目录错误



我在谷歌colab 中尝试了以下代码的多种变体,但没有成功(使用、\等(

file = r"C:UserswalteOneDriveDocumentsNairobi.pdf"
table = tabula.read_pdf(file, pages=26)
table[0]
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\walte\OneDrive\Documents\Nairobi.pdf.pdf'

错误显示:«FileNotFoundError:[Erno 2]没有这样的文件或目录:"C:\Users\walte\OneDrive \Documents \Nairobi.pdf"»

看起来tabula.read_pdf正在自动将.pdf添加到路径中。

我认为«file=r"C: \Users\walte\OneDrive \Documents\Nairobi"»将是解决方案。

最新更新