Answers for "open a file in explorer in python"

3

how to open file explorer in python

import os
import subprocess
FILEBROWSER_PATH = os.path.join(os.getenv('WINDIR'), 'explorer.exe')

def explore(path):
    # explorer would choke on forward slashes
    path = os.path.normpath(path)

    if os.path.isdir(path):
        subprocess.run([FILEBROWSER_PATH, path])
    elif os.path.isfile(path):
        subprocess.run([FILEBROWSER_PATH, '/select,', os.path.normpath(path)])
Posted by: Guest on May-26-2020
0

python open file from explorer

import sys
path = r'C:Program Files (x86)IronPython 2.7Lib'
sys.path.append(path)

import subprocess
subprocess.Popen('explorer "C:temp"')
Posted by: Guest on July-17-2020

Code answers related to "open a file in explorer in python"

Python Answers by Framework

Browse Popular Code Answers by Language