Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 372 Bytes

print 输出.md

File metadata and controls

19 lines (15 loc) · 372 Bytes
import sys
import os
class Logger(object):
    def __init__(self, fileN="default.log"):
        self.terminal = sys.stdout
        self.log = open(fileN, "a")
 
    def write(self, message):
        self.terminal.write(message)
        self.log.write(message)
 
    def flush(self):
        pass
    
 # print 前调用 
 sys.stdout = Logger('datalog.txt')