【发布时间】:2019-12-12 00:35:39
【问题描述】:
我正在编写一个脚本来打开和搜索 macOS 字典应用程序
在终端,我可以这样做
open dict://cheeseburger
应用打开到芝士汉堡入口
使用 python 的 subprocess 模块,我可以做到这一点:
subprocess.Popen(["path_to_dictionary_app"])
应用打开
如何在子流程中包含搜索词?
【问题讨论】:
标签: python macos subprocess
我正在编写一个脚本来打开和搜索 macOS 字典应用程序
在终端,我可以这样做
open dict://cheeseburger
应用打开到芝士汉堡入口
使用 python 的 subprocess 模块,我可以做到这一点:
subprocess.Popen(["path_to_dictionary_app"])
应用打开
如何在子流程中包含搜索词?
【问题讨论】:
标签: python macos subprocess
Popen 的语法是subprocess.Popen(['command','arg1', 'arg2'])。
在你的情况下:
search = 'cheeseburger'
args = ['open','dict://'+search]
subprocess.Popen(args)
【讨论】: