python

python 的调试,令人非常忧伤,通过将输出路径打印的方式,可以提高很大的方便性:

import sys
#coding=utf-8
def get_cur_info():
       print sys._getframe().f_code.co_filename  #当前文件名,可以通过__file__获得
       print sys._getframe().f_code.co_name  #当前函数名
       print sys._getframe().f_lineno #当前行号

       return "{"info":"print info":"%s"}" % (sys._getframe().f_code.co_filename)
       return "{"info":"print info":"%s"}" % (sys._getframe().f_code.co_name)
       return "{"info":"print info(%d)"}" % (sys._getframe().f_lineno)

  

原文地址:https://www.cnblogs.com/blitheG/p/5342271.html