Open document with default OS application in Python, both in Windows and Mac OS

前端 未结 13 1719
刺人心
刺人心 2020-11-22 10:36

I need to be able to open a document using its default application in Windows and Mac OS. Basically, I want to do the same thing that happens when you double-click on the do

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 11:15

    on mac os you can call 'open'

    import os
    os.popen("open myfile.txt")
    

    this would open the file with TextEdit, or whatever app is set as default for this filetype

提交回复
热议问题