【发布时间】:2019-09-30 03:32:40
【问题描述】:
我想用 python 代码向我的 mac 的通知中心发送通知。
我在 macOS Mojave 版本 10.14.6 上使用 python3,Atom 作为我的编辑器。我尝试过使用不同的方法,例如 notify2(没有用,dbus 存在我无法解决的问题)和 notify-send(回复 RuntimeError: Unsupported operating system: darwin)。所以,现在,我正在尝试使用 OS 模块。到目前为止,这是我的代码:
import os
mstr='Hello'
os.system('notify-send '+mstr)
当我从终端运行它时,它会输出sh: notify-send: command not found。如果我从 Python 的默认编辑器 IDLE 运行它,什么也不会发生。
我该怎么办?还有其他发送通知的方法吗?
【问题讨论】:
标签: python python-3.x macos