繁体   English   中英

如何在python中打开mac osx上的文件

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM