开发者

Creating space in between written lines

I'm currently creating a function that reads in data from other functions and writing it out to a text file on my desktop.

def outputResults(filename):
"""This function开发者_StackOverflow中文版 serves to output and write the results from analyzeGenome.py to a text file \
   Input: filename of output file, dictionary of codon frequencies, dictionary of codon counts \
        GC-content, FASTA header, & sequence length

   Output: Text file containing all the above """

outString = "Header = %s" %header
filename.write(outString)

outString2 = "Sequence Length = %.3F MB" % length
filename.write(outString2)

When I do this, python prints the lines one after another in the text file. How can I print onto the next line and add a space in between the lines?


You need to append a linebreak. http://docs.python.org/library/stringio.html

output.write('First line.\n')


Instead of write, use writelines, which prints everything in the sequence out to a file on its own line. Add a blank string to add double spacing

  filename.writelines([outString, "", outString2]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜