测试用例日志模块编写:

import time
#定义Loginfo类
class Loginfo(object):
#定义打开日志功能:
def __init__(self,path = "",mode = "w"):
fname = path + time.strftime("%Y-%m-%d",time.gmtime())
self.log = open(path + fname + ".txt",mode,encoding="utf-8")
#定义写日志功能:
def log_write(self,msg):
self.log.write(msg)
#定义关闭日志功能:
def log_close(self):
self.log.close()
if __name__ == '__main__':
log = Loginfo()
log.log_write("test Loginfo 测试")
log.log_close()
上一篇:Django 聚合函数使用


下一篇:O(1) 时间插入、删除和获取随机元素