printing - Send output of print to a new file in python? -


this question has answer here:

in section of program i'm making converted plain sequence of letters fasta format. need take fasta format , put in file form can send program come later in code. in line 3 created "fasta.txt". need put output of line 8, fastaform, in file. in last line tried didn't work , have no idea how. feel should pretty simple i'm new @ this.

infname = sys.argv[2] handle = open(infname, "r") file = open("fasta.txt", "w") line in handle:         linearr = line.split()         seqid = linearr[0]         seq = linearr[1]         fastaform = (">%s\n%s\n" % (seqid,seq))         print fastaform >> "fasta.txt" 

try

file.write(fastaform) file.close() 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -