随笔: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()
原文地址:https://www.cnblogs.com/caodingzheng/p/14007076.html