python脚本的文件名和行号 [英] filename and line number of python script

查看:104
本文介绍了python脚本的文件名和行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取python脚本中的文件名和行号。

How can I get the file name and line number in python script.

正是从异常追溯得到的文件信息。在这种情况下,不会引发异常。

Exactly the file information we get from an exception traceback. In this case without raising an exception.

推荐答案

inspect.currentframe().f_back.f_lineno

ActiveState Code

这篇关于python脚本的文件名和行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆