open choose files from file explorer python 1

open choose files from file explorer python

import tkinter as tk
from tkinter import filedialog

root = tk.Tk()
root.withdraw()

files = filedialog.askopenfilenames()

Here is what the above code is Doing:
1. Create a Tk root widget
2. Hide it
3. Create the file dialog
4. Show the dialog and wait for user interaction
5. Save the result of the dialog in a variable
6. Destroy the root widget
7. Print the result

Similar Posts