gpt4 book ai didi

python - 属性错误 : 'module' object has no attribute 'startfile'

转载 作者:行者123 更新时间:2023-11-28 21:15:37 30 4
gpt4 key购买 nike

尝试运行此 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

关于python - 属性错误 : 'module' object has no attribute 'startfile' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29823028/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com