随笔: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()

版权声明:本文为caodingzheng原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。