Python - How to get the filename in tkinter file dialog
Question: I am trying to get just the file name of the selected file in tkinter file
dialog

Here's my code:

    
    
    def browseFile(self):
        root = tk.Tk()
        root.withdraw()
        file_path = askopenfilename(filetypes=(("Video files", "*.mp4;*.flv;*.avi;*.mkv"),
                                           ("All files", "*.*") ))
    
        print file_path
    

What I am getting with this code is the whole path of the selected file, where
I only need the file name. How can I do it?

results with my code:

    
    
     C:/Users/Guest/vid1.mp4
    

what I want:

    
    
     vid1.mp4
    


Answer: 
    >>> import os
    >>> s = "C:/Users/Guest/vid1.mp4"
    >>> os.path.split(s)
    ('C:/Users/Guest', 'vid1.mp4')
    >>> os.path.split(s)[1]
    'vid1.mp4'
    

Alternatively,

    
    
    >>> os.path.basename(s)
    'vid1.mp4'
    

