class HangUp(object): current_path = os.getcwd() test_path = current_path + r‘/log/‘ log_name = test_path + time.strftime(‘%Y-%m-%d %H-%M-%S‘) + ".log" nowtime = time.time() def write_log(self, string, false_time=0.0, data=1814400.0): with open(self.log_name, "a") as f: save_time = time.strftime(‘%Y-%m-%d %H:%M:%S‘, time.localtime(self.nowtime - data + false_time)) print(save_time + ": " + string) f.write(‘\r\n‘ + save_time + ": " + string) f.close()
修改LOG时间
原文:https://www.cnblogs.com/gexbooks/p/12658616.html