我正在創建一個函數,該函數從其他函數中讀取數據並將其寫入到我的桌面上的文本文件中。在書面行之間創建空間
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