python中的logging模块怎么使用-python中的logging模块使用方法
作者:快盘下载 人气:小伙伴们知道python中的logging模块怎么使用吗?今天小编就来讲解logging模块的使用方法,感兴趣的快跟小编一起来看看吧,希望能够帮助到大家。
第一步:打开python的编辑器pycharm,在python文件中导入一个logging模块。

第二步:接着在下面新建一个函数main,在这个函数里面打印10/0,显然这是一个错误,等一下执行的时候会有错误提示!

第三步:然后使用try语句,在下面调用main函数,对main函数进行检测。

第四步:如果有错误,执行exception这个错误类,通过logging这个模块将错误的信息打印出来,但是后面的代码还是会继续执行!

第五步:在后面写上print(“end”),观察是否被执行!

第六步:点击顶部的运行命令run,选择要运行的文件。

第七步:在下面的控制台我们就可以看到打印出来的错误以及后面的代码继续执行的结果了。

以上就是小编给大家带来的python中的logging模块怎么使用的全部内容,希望能够帮助到大家哦。
加载全部内容