how to openn file dialog in tkinter

from tkinter import filedialog
text_file=filedialog.askopenfilename(initialdir="D:/IT related folders and documents/",title="Open Text File",filetypes=(("Text Files", "*.txt"),))

Here is what the above code is Doing:
1. We are importing the filedialog module from the tkinter package.
2. We are creating a variable called text_file and assigning it to the result of the filedialog.askopenfilename() function.
3. The filedialog.askopenfilename() function takes in a few arguments.
a. initialdir: This is the directory that the file dialog opens in.
b. title: This is the title of the file dialog.
c. filetypes: This is a tuple of file types that the file dialog will allow you to select.