放在程序开头就可以了
import sys
import os
class Logger(object):
def __init__(self, filename="Default.log"):
self.terminal = sys.stdout
self.log = open(filename, "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def flush(self):
pass
type = sys.getfilesystemencoding()
sys.stdout = Logger("left_process.txt")