函数-(记录日志功能)

时间:2019-11-01 13:20:38   收藏:0   阅读:85

函数-(记录日志功能)

#_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

技术分享图片

原文:https://www.cnblogs.com/startl/p/11776167.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!