自省: 当前执行行数

题面

samson <[email protected]>
reply-to        [email protected]
to      python-cn`CPyUG`华蟒用户组 <[email protected]>
date    Sun, Feb 1, 2009 at 10:45
subject [CPyUG:77839] 怎样在程序中动态获得当前所执行的行号

smallfish:traceback()

smallfish <[email protected]>
reply-to        [email protected]
to      [email protected]
date    Sun, Feb 1, 2009 at 10:48

试试看

   1 import traceback
   2 print traceback.extract_stack()[0][1]

AlbertLee

http://blog.csdn.net/albertlee/archive/2004/11/10/175818.aspx


反馈

创建 by -- ZoomQuiet [2009-02-02 04:05:33]

MiscItems/2009-02-02 (last edited 2009-12-25 07:14:54 by localhost)