我正在構建一個簡單的應用程式,它將pdf轉換為png。
當我使用:
pdf_name = askopenfilenames(initialdir="/", title="Selecionar Arquivos")
我得到:
print(pdf_name)
('C:/Users/user/Desktop/Apps/Python/Conversor img to pdf/file.pdf',)
所以,問題是:
我如何獲得這種型別?
print(pdf_name)
'C:/Users/user/Desktop/Apps/Python/Conversor img to pdf/file.pdf'
uj5u.com熱心網友回復:
有兩種方法可以做到這一點。
第一的
pdf_name = askopenfilenames(initialdir="/", title="Selecionar Arquivos")
print(pdf_name[0])
其次,askopenfilenames你應該嘗試而不是askopenfilename。
另外,不要忘記匯入這個from tkinter.filedialog import askopenfilename。
pdf_name = askopenfilename(initialdir="/", title="Selecionar Arquivos")
print(pdf_name)
兩者的輸出相同
'C:/Users/user/Desktop/Apps/Python/Conversor img to pdf/file.pdf'
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/465742.html
