【发布时间】:2021-06-25 07:58:24
【问题描述】:
制作一个可以在听命令时打开应用程序的程序。应用程序名称存储在变量“a”中。然后用以下行打开:
os.system("open /Applications/" + a + ".app")
但有时系统上可能不存在“a”,例如控制台打印的“音乐”:
The file /Applications/music.app does not exist.
python 代码完全停止。
我怎么知道控制台给出了这个错误并阻止程序停止?
【问题讨论】: