AttributeError: 'module' 对象没有属性 'startfile' [英] AttributeError: 'module' object has no attribute 'startfile'

查看:48
本文介绍了AttributeError: 'module' 对象没有属性 'startfile'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试运行这个 程序,我收到这个错误:

Trying to run this program, I got this error:

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

如何解决这个问题?

推荐答案

在 Linux 上你可以使用:

On Linux you can use:

import subprocess, sys

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

摘自此处

这篇关于AttributeError: 'module' 对象没有属性 'startfile'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆