函数-(记录日志功能)

函数-(记录日志功能)

#_author:xing
#date:2019/11/1
import time
def fun(n):
time_format='%Y-%m-%d %X'
current_time=time.strftime(time_format)
with open('record_log','a',encoding='utf8') as f:
f.write('end function %s,%s\n'%(n,current_time))

def function1(n):
print('starting action1')
fun(n)
def function2(n):
print('starting action1')
fun(n)
def function3(n):
print('starting action1')
fun(n)
function1(1)
function2(2)
function3(3)
Output:

starting action1
starting action1
starting action1

posted @ 2019-11-01 11:53  Stary_tx  阅读(233)  评论(0编辑  收藏  举报