例子:
import time
def logger():
time_format = "%Y-%m-%d %X" #格式化输出时间
timess = time.strftime(time_format)
with open("aaaa","a+",encoding="utf-8")as f:
f.write ("%s in the func: \n"% timess)
def func1():
logger()
def func2():
logger()
func1()
func2()
输出为:
原文:https://www.cnblogs.com/nxb-1573/p/14198691.html