您的位置:首页 > 编程语言 > Python开发

Python:一个不错的日志思想

2018-01-15 18:46 197 查看
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : my_func.py
# @Author: wmy
# @Date  : 2018/1/15
#
import time
def log():
time_format = '%Y - %m - %d: %X'
time_current = time.strftime(time_format)
with open('log.txt', 'a+') as f:
f.write('%s end !\n' %time_current)

def get_up():
print('func 1: get_up')
log()

def eating():
print('fun 2: eating')
log()

def sleep():
print('func 3: sleep')
log()
count = 0;
while count <10:
get_up()
eating()
sleep()
count +=1

日志对于一个软件系统来说很重要:本文借鉴的函数写日志思想还是值得学习的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: