##language:zh #pragma section-numbers off ##含有章节索引导航的 ZPyUG 文章通用模板 <> ## 默许导航,请保留 <> = 自省: 当前执行行数 = ##startInc == 题面 == {{{ samson reply-to python-cn@googlegroups.com to python-cn`CPyUG`华蟒用户组 date Sun, Feb 1, 2009 at 10:45 subject [CPyUG:77839] 怎样在程序中动态获得当前所执行的行号 }}} === smallfish:traceback() === {{{ smallfish reply-to python-cn@googlegroups.com to python-cn@googlegroups.com date Sun, Feb 1, 2009 at 10:48 }}} 试试看 {{{#!python import traceback print traceback.extract_stack()[0][1] }}} === AlbertLee === http://blog.csdn.net/albertlee/archive/2004/11/10/175818.aspx ##endInc ---- '''反馈''' 创建 by -- ZoomQuiet [<>]