gpt4 book ai didi

python - 尝试在 Mac 上更改桌面壁纸时出现 "OSERROR -10000 Apple event handler failed"

转载 作者:行者123 更新时间:2023-12-01 06:19:52 31 4
gpt4 key购买 nike

我编写了以下非常简单的 python 脚本来更改我的 mac 上的桌面壁纸(基于此 thread ):

from appscript import app, mactypes
import sys

fileName = sys.argv[1:]

app('Finder').desktop_picture.set(mactypes.File(fileName))

但是,当我运行它时,我得到以下输出:

Traceback (most recent call last):
File "../Source/SetWallPaper2.py", line 6, in app('Finder').desktop_picture.set(mactypes.File(fileName)) File "/Library/Python/2.5/site-packages/appscript-0.19.0-py2.5-macosx-10.5-i386.egg/appscript/reference.py", line 513, in call appscript.reference.CommandError: Command failed: OSERROR: -10000 MESSAGE: Apple event handler failed. COMMAND: app(u'/System/Library/CoreServices/Finder.app').desktop_picture.set(mactypes.File(u"/Users/Daniel/Pictures/['test.jpg']"))

我进行了一些网络搜索,但找不到任何内容可以帮助我弄清楚 OSERROR -10000 的含义或如何解决该问题。

最佳答案

文件名 = sys.argv[1]代替文件名 = sys.argv[1:]

mactypes.File(u"/Users/Daniel/Pictures/['test.jpg']")

看到文件名周围的方括号和引号了吗?

关于python - 尝试在 Mac 上更改桌面壁纸时出现 "OSERROR -10000 Apple event handler failed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/881041/

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