繁体   English   中英

如何使用python子进程在macos字典中查找单词

[英]How to look up a word in macos dictionary with python subprocess

我正在编写一个脚本来打开和搜索 macOS 词典应用程序

在终端,我可以做到这一点

open dict://cheeseburger

然后应用程序打开芝士汉堡条目

使用 python 的 subprocess 模块,我可以这样做:

subprocess.Popen(["path_to_dictionary_app"])

然后应用程序打开

如何在子流程中包含搜索词?

Popen的语法是Popen subprocess.Popen(['command','arg1', 'arg2'])

在你的情况下:

search = 'cheeseburger'
args = ['open','dict://'+search]
subprocess.Popen(args)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM