zoukankan      html  css  js  c++  java
  • Jupyter 程序运行"成功/报错"具有声音提示的模板

    利用Jupyter进行数据批量处理的时候,有时耗时较长,希望利用这段时间去做其他事情,想通过声音提示来判断Jupyter的程序运行状态,运行成功/报错则弹出相应提示音。
    实现思路是先创建播放提示声音的函数,在需要提示的代码部分添加try except判断运行状态,实现代码的模板如下:

    from IPython.display import Audio, display
    def tip_error():
      display(Audio(url='https://www.feffery.club/error.mp3', autoplay=True))
    def tip_success():
      display(Audio(url='https://www.feffery.club/success.mp3', autoplay=True))
    
    try:
        """ 
        // 编写运行代码 //
        """
        tip_success()
    except Exception as e:
        print(e)
        tip_error()
    

    Jupyter notebook 效果举例

  • 相关阅读:
    Python 字符串
    python 元组用法
    python 字典用法
    环境配置
    桥式整流以及电容作用
    三角序列的正交性
    MDS
    ISOMAP
    randperm
    数据库~Mysql里的Explain说明
  • 原文地址:https://www.cnblogs.com/lqqgis/p/12850202.html
Copyright © 2011-2022 走看看