I am surprised no one has mentioned using xdg-open
for *nix which will work for both files and folders:
import os
import platform
import subprocess
def open_file(path):
if platform.system() == "Windows":
os.startfile(path)
elif platform.system() == "Darwin":
subprocess.Popen(["open", path])
else:
subprocess.Popen(["xdg-open", path])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…