1

我编写了以下非常简单的 python 脚本来更改我的 Mac 上的桌面墙纸(基于此线程):

from appscript import app, mactypes
import sys 

fileName = sys.argv[1:]

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

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

回溯(最后一次调用):
文件“../Source/SetWallPaper2.py”,第 6 行,在 app('Finder').desktop_picture.set(mactypes.File(fileName)) 文件“/Library/Python/2.5 /site-packages/appscript-0.19.0-py2.5-macosx-10.5-i386.egg/appscript/reference.py”,第 513 行,调用 appscript.reference.CommandError:命令失败:OSERROR:-10000 消息: Apple 事件处理程序失败。命令:app(u'/System/Library/CoreServices/Finder.app').desktop_picture.set(mactypes.File(u"/Users/Daniel/Pictures/['test.jpg']"))

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

4

1 回答 1

2

fileName = sys.argv[1] 代替 fileName = sys.argv[1:]

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

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

于 2009-05-19T06:59:03.033 回答