I am writing a script to open and search the macOS dictionary application
In terminal, I can do this
open dict://cheeseburger
and the app opens to the cheeseburger entry
Using python's subprocess module, I can do this:
subprocess.Popen(["path_to_dictionary_app"])
and the app opens
How do I include a search word in the subprocess?
The syntax of Popen
is subprocess.Popen(['command','arg1', 'arg2'])
.
In your case:
search = 'cheeseburger'
args = ['open','dict://'+search]
subprocess.Popen(args)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.