我正在做一个关于从python更改我的壁纸的学校项目,它在终端中完美地工作但我需要从我的文本编辑器,原子这样做,它似乎不起作用。我已经尝试重新排列撇号,因为它可能就是这样,但似乎无法使它起作用。
这完美适用于终端:
osascript -e 'tell application "System Events" to set picture of every desktop to ("/Users/carlaa/Desktop/DEVf/python/APODkata/apodimage.jpg" as POSIX file as alias)'
但是来自atom表示无效语法
from subprocess import call
subprocess.call(["osascript -e 'tell application "System Events" to set picture of every desktop to ("/Users/carlaa/Desktop/DEVf/python/APODkata/apodimage.jpg" as POSIX file as alias)'",shell=True])
答案 0 :(得分:1)
您需要转义这些双引号并删除subprocess
:
from subprocess import call
call(["osascript -e 'tell application \"System Events\" to set picture of every desktop to (\"/Users/carlaa/Desktop/DEVf/python/APODkata/apodimage.jpg\" as POSIX file as alias)'", shell=True])