您的位置:首页 > 编程语言 > Python开发

python 获取当前函数名和行号

2015-07-03 11:23 741 查看
sys._getframe([depth])
Return a frame object from the call stack. If optional integer depth is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, ValueError is
raised. The default for depth is zero, returning the frame at the top of the call stack.

CPython implementation detail: This function should be used for internal and specialized purposes only. It is not guaranteed to exist in all implementations of Python.

<span style="font-family:Arial;font-size:18px;"><strong>sys._getframe(1).f_code.co_name
sys._getframe().f_back.f_code.co_name</strong></span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: