Is there an platform independent equivalent of os.startfile()?

后端 未结 3 1914
迷失自我
迷失自我 2020-12-01 03:08

I want to run a program on several platforms (including Mac OS), so I try to keep it as platform independent as possible. I use Windows myself, and I have a line os.st

3条回答
  •  时光说笑
    2020-12-01 03:21

    It depend what you mean with platform independent. If your question is about how to open anything using the default action of the OS, for example, when you double click on some file to let the OS decide how to open it, then the simple answer is no.

    However, to implement this functionality yourself, is very easy, but you need to use a few different methods to accommodate for different OS's. That said, the most forgiving method is to use os.system(WinPathWithArgs) as I have explained in this answer.

提交回复
热议问题