Answers:
您可以将其notify-send用作外部命令:
import subprocess as s
s.call(['notify-send','foo','bar'])
或者,您可以使用notify2模块(sudo apt install python3-notify2):
import notify2
notify2.init('foo')
n = notify2.Notification('foo', 'bar')
n.show()
软件包中包含更多示例(请参阅参考资料/usr/share/doc/python3-notify2/examples/)。
subprocess是随Python分发的标准库。因此,无需将其安装为第三方库。[ref:docs.python.org/2/library/index.html]
notify-send。或者至少必须在Kubuntu上。也许它是Ubuntu上默认提供的,在那种情况下,它确实是最好的解决方案。