python中获取当前位置所在的行号和函数名 简单版 def get_cur_info(): print sys._getframe().f_code.co_name print sys._getframe().f_back.f_linenoget_cur_info() 参考:http://my.oschina.net/qihh/blog/74244