Reputation: 11
I want to store the filepath to an opened file (via askopenfilename in tkinter) into a variable and later on use it for other purposes such as reading the file through the variable and use its values. How do I do that?
Also I am an absolute beginner so please explain the procedure too. Thanks in advance.
Upvotes: 0
Views: 247
Reputation: 45
Here is a code to start you off
from tkinter import filedialog as fd
filename = fd.askopenfilename(title = "Attach file", initialdir = 'c:/')
f = open(filename, "r")
print(f.read())
f.close()
Upvotes: 1