DWQA QuestionsCategory: ServerHow does pyqt5 open files by default?
The charge is too low asked 1 month ago

For example, after you double-click the HTML file in the GUI interface, you can open the file with the default browser
Does pyqt5 have such a function or method?

1 Answers
Feng_Yu answered 1 month ago

I don’t know if Python has a built-in solution. You can check it.
I think you can call the built-in operating system directlyopen fileLet the operating system decide how to open. For example, the windows program isexplorer.exeThis program for Linux isxdg-openAnd the Mac OS program isopen
For example, if you judge that the current operating system is windows, you can use:

os.system('explorer.exe "path\to\file"')