最近总是需要进行调试,又不想写入文件所以....直接上代码
环境windows10
pyhton版本2.7 64位
好处接受任何类型的参数
输出信息格式:文件名称 函数名称 行号 调试信息
===================================================
#coding:utf-8
import os,sys
import time
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
#是否输出打印信息
print_SIGN=True;
def printt(everything):
if print_SIGN:
py_file=sys._getframe(0).f_back.f_code.co_filename.split("\\")[-1];
py_file=py_file.ljust(15," ");
func_name=sys._getframe(0).f_back.f_code.co_name;
if func_name!="<module>":func_name=func_name+"()";
else:func_name="--------";
func_name=func_name.ljust(10," ");
lines=str(sys._getframe(0).f_back.f_lineno).ljust(5," ");
print ("{} {} {} {} {}".format(py_file,GetTime(),func_name,lines,everything));
printt("everything");