python 记录日志的类
2020-05-02 python 1072
import os, time class Log: def __init__(self, file): self.file = file def record(self, content): with open(self.file, "a+", encoding="utf-8") as f: f.write("{0}:{1}\n".format(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), content)) def write(self, file, content): with open(file, "w", encoding="utf-8") as f: f.write(content) def outfile(self, file): path = os.path.dirname(file) return os.path.join(path, "success_" + os.path.basename(file))
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论