Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: How to open a folder on Windows Explorer(Python 3.6.2, Windows 10)

Tags:

If I store the path that i want to open in a string called finalpath which looks something like this: "./2.8 Movies/English/Die Hard Series"

then how do i open this in Windows Explorer?(Windows 10)(Python 3.6.2)

P.S I know many people have asked this question but I did not find them clear. Please answer soon.

like image 669
Vikhyat Agarwal Avatar asked Dec 14 '17 11:12

Vikhyat Agarwal


People also ask

How do I open a folder in Explorer using Python?

In order to do so, we have to import the filedialog module from Tkinter. The File dialog module will help you open, save files or directories. In order to open a file explorer, we have to use the method, askopenfilename(). This function creates a file dialog object.

How do I navigate to a folder in Python?

To find the current working directory in Python, use os. getcwd() , and to change the current working directory, use os. chdir(path) .

How do I run a Python script in Windows 10?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World! If everything works okay, after you press Enter , you'll see the phrase Hello World!


1 Answers

I found a simple method.

import os path = "C:/Users" path = os.path.realpath(path) os.startfile(path) 
like image 110
Vikhyat Agarwal Avatar answered Sep 28 '22 09:09

Vikhyat Agarwal