用python打开文件夹的三种方式
一、利用explorer.exe
import os
# 利用explorer.exe执行
start_directory = r'C:\代码\软件包'
os.system("explorer.exe %s" % start_directory)
二、用os.startfile
import os
start_directory = r'C:\代码\软件包'
os.startfile(start_directory)
三、利用subprocess
import os
import subprocess
# 利用subprocess
def startfile(filename):
try:
os.startfile(filename)
except:
subprocess.Popen(['xdg-open', filename])
start_directory = r'C:\代码\软件包'
startfile(start_directory)