2012-08-10 111 views

回答

1

您可以使用

inspect.getsourcelines(執行)

爲得到自己的代碼。

In [1]: def testthis(): print "hello" 

In [2]: import inspect 

In [3]: inspect.getsourcelines(testthis) 
Out[3]: ([u'def testthis(): print "hello"\n'], 1)