如何将我的python脚本的输出重定向到新文件?

时间:2018-11-28 12:26:11

标签: python redirect output

请我将python脚本的输出重定向为txt格式或csv格式,而不使用linux的重定向命令行。谢谢。

with open('data1.csv', 'r') as f:
    for line in f.readlines():
        line = line.replace("\n", "")
        full_name = line.split('\t')
        accession_x = full_name[0]

        with open('data2.csv', 'r') as f1:
            for line1 in f1.readlines()[1:]:  # ignores the first line
                line1 = line1.replace("\n", "")

                full_name1 = line1.split(' ')
                accession_y = full_name1[0].replace(" ", "")
                accession_z = full_name1[1].replace(" ", "")
                main_accession = accession_x + " " + accession_z + " " + access$

                if accession_x == accession_z:

0 个答案:

没有答案