随笔:Python打印临时日志、清空临时日志

随笔:Python打印临时日志、清空临时日志

import time
# 打印临时日志、清空临时日志
class Temporary_log(object):

    def temporary_log(self, value, dir):
        file = dir+'/temporary_log.log'
        file_handle = open(file, 'a', encoding='utf-8')
        file_handle.write(value)
        file_handle.close()

    def clear_log(self, dir):
        file = dir+'/temporary_log.log'
        file_handle = open(file, 'w', encoding='utf-8')
        file_handle.write('')
        file_handle.close()
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页