How can I get folder where is stored file selected from tkinter filedialog
?
I want make something such this:
from tkinter import filedialog as fd filename = fd.askopenfilename() print(filename.directory)
Advertisement
Answer
You could use os.path.dirname
for that.
from tkinter import filedialog as fd import os filename = fd.askopenfilename() print(os.path.dirname(filename))