保存python输出数据的结果代码

class Logger(object):
    def __init__(self, filename='default.log', stream=sys.stdout):
        self.terminal = stream
        self.log = open(filename, 'w')
    def write(self, message):
        self.terminal.write(message)
        self.log.write(message)
    def flush(self):
        pass
sys.stdout = Logger('shape5.log', sys.stdout)#全部显示
#np.set_printoptions(threshold = np.inf)

将python控制台数据保存为csv文件

with open("D:/PycharmProjects/D_pythonProject1/AttCRISPR-master/data/bio_feature.csv",'w',newline='')as f: #创建writer对象 writer=csv.writer(f) writer.writerows(X_biofeat)#写入数据

你可能感兴趣的:(python,开发语言)