我对python和applescript很陌生。我有一个调用 2 个 applescripts 的 python 脚本。我想在 python 中定义几个全局变量并传递给 applescript 1 ,这些值将由 applescripts 1 中的不同函数修改,然后传回 python 脚本,然后将这些值传递给 applescript 2 使用。
我用谷歌搜索了一下,我尝试了以下方法:
在苹果脚本中,
on run argv
if (item 1 of argv is start with "x") then
function1(item1 of argv)
else
function2 (item 1 of argv)
function3 (item 2 of argv)
end run
on function1 (var)
set var to (something code to get value from interaction with user)
return var
end function1
在 python 脚本中导入 os 导入 sys
os.system ('osascript Setup.scpt')
variable1 = sys.argv[1]
variable2 = sys.argv[2]
在applescript2中,我做了与applescirpt1类似的事情。
然而,这并没有奏效。我试图打印出两个脚本中的所有 argv,看起来值没有正确传递。谁能给我更多的指导?谢谢!