[英]How to open a file on mac osx in python
我正在嘗試使用 eclipse 在 python 中打開 mac 上的文件。
FileName = "/Users/fis/Desktop/installation_guide.txt"
ss = subprocess.Popen(FileName, shell=True)
ss.communicate()
還有os.popen(FileName)
。 但是文件沒有打開。 這些代碼在 Windows 中運行良好。 但是,我不知道mac有什么問題。 我想打開一個文件,就像雙擊windows打開文件一樣,而不是像在控制台中讀取文件內容和打印一樣。 文件存在於 Mac 上的桌面位置
使用open
(1)命令。
import subprocess
FileName = "/Users/fis/Desktop/installation_guide.txt"
subprocess.call(['open', FileName])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.