尝试运行此program,出现以下错误:

Traceback (most recent call last):
  File "piltk.py", line 84, in <module>
    os.startfile(filename)
AttributeError: 'module' object has no attribute 'startfile'

如何解决这个问题?

最佳答案

在Linux上,您可以使用:

import subprocess, sys

opener = "open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, filename])
here采纳

10-08 05:02