【问题标题】:How to look up a word in macos dictionary with python subprocess如何使用python子进程在macos字典中查找单词
【发布时间】:2019-12-12 00:35:39
【问题描述】:

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

在终端,我可以这样做

open dict://cheeseburger

应用打开到芝士汉堡入口

使用 python 的 subprocess 模块,我可以做到这一点:

subprocess.Popen(["path_to_dictionary_app"])

应用打开

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

【问题讨论】:

    标签: python macos subprocess


    【解决方案1】:

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

    在你的情况下:

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

    【讨论】:

      猜你喜欢
      • 2013-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多