[英]PDF2IMAGE - Path not found
我在使用 pdf2image 模塊進行轉換時遇到問題。 我不知道代碼哪里出了問題。 當我運行程序並粘貼路徑時,會顯示錯誤。
下面的代碼:
import os
from pdf2image import convert_from_path
from tkinter import *
from tkinter import messagebox
def convert():
try:
for img in images:
for idx, img in enumerate(images, start=1):
img.save(os.path.join(os.cudir,'new_folder',f"image_{idx}.jpg"))
except:
Result = "FileNotFoundError"
messagebox.showinfo("Result", Result)
else:
Result = "success"
messagebox.showinfo("Result", Result)
master = Tk()
Label(master, text="File Location").grid(row=0, sticky=W)
e1 = Entry(master)
e1.grid(row=0, column=1)
b = Button(master, text="Convert", command=convert)
b.grid(row=0, column=2,columnspan=2, rowspan=2,padx=5, pady=5)
mainloop()
這只是一個猜測,但是文件夾os.path.join(os.cudir,'new_folder')
是否已經存在? 這段代碼似乎假設它確實如此。
嘗試打印有關錯誤的更多信息:
except Exception as e:
Result = f"FileNotFoundError: {e}"
messagebox.showinfo("Result", Result)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.