在书写行之间创建空间

Fra*_*cis 1 python io file-io

我目前正在创建一个函数,该函数从其他函数读取数据并将其写入桌面上的文本文件.

def outputResults(filename):
"""This function 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)
Run Code Online (Sandbox Code Playgroud)

当我这样做时,python在文本文件中一个接一个地打印行.如何打印到下一行并在行之间添加空格?

Mat*_*hew 5

你需要附加一个换行符. http://docs.python.org/library/stringio.html

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