如何用python写监控日志函数

def write_log(username,operation):
'''
写日志函数
:param username:用户名
:param operation:用户的操作信息
:return:
'''
w_time = time.strftime('%Y-%m-%d %H%M%S')
with open('log.txt','a+') as fw:
log_content = '%s %s %s \n'%(w_time,username,operation)
fw.write(log_content)


posted @ 2017-06-17 13:32  sjuexin  阅读(837)  评论(0编辑  收藏  举报