How to open a file on mac OSX 10.8.2 in python

后端 未结 3 1641
囚心锁ツ
囚心锁ツ 2021-01-29 10:18

I am writing a python code on eclipse and want to open a file that is present in Downloads folder. I am using MAC OSX 10.8.2. I tried with f=os.path.expanduser(\"~/Downloa

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 11:05

    I am hesitant to answer because this question was double-posted and is confusingly phrased, but... if you want to "open" the file in OSX using the default editor, then add the open command to your subprocess. This works for me:

    subprocess.Popen("open myfile.txt",shell=True)
    

提交回复
热议问题