尝试运行此程序,出现此错误:
Traceback (most recent call last):
File "piltk.py", line 84, in <module>
os.startfile(filename)
AttributeError: 'module' object has no attribute 'startfile'
Run Code Online (Sandbox Code Playgroud)
如何解决呢?
在Linux上,您可以使用:
import subprocess, sys
opener ="open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, filename])
Run Code Online (Sandbox Code Playgroud)
从这里采用