如何用python写监控日志函数

 我来答
千锋教育
2017-06-27 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
展开全部
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)

希望对你有帮助!

bt...0@sohu.com
2017-06-26 · TA获得超过290个赞
知道小有建树答主
回答量:243
采纳率:59%
帮助的人:50.1万
展开全部
12345678910111213>>> from functools import reduce>>> help(reduce)Help on built-in function reduce in module _functools: reduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates ((((1+2)+3)+4)+5). If initial is present, it is placed before the items of the sequence in the calculation, and serves as a default when the sequence is empty.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式