我正在创建一个函数,该函数从其他函数中读取数据并将其写入到我的桌面上的文本文件中。在书面行之间创建空间
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)
当我这样做时,python在文本文件中一个接一个地打印行。我如何打印到下一行并在行之间添加空格?
在我的代码而言,哪里断行去? – Francis 2011-04-26 17:24:16
@Francis在你想要换行的地方,'\ n'就在字符串中。看起来像是在'%s'之后 – Matthew 2011-04-27 21:21:43