[Tutor] write list to columns

शंतनू shantanoo at gmail.com
Thu Apr 12 04:51:39 CEST 2012


On 12-Apr-2012, at 8:01 AM, questions anon wrote:

> I am trying to simply write a list of values to txt file in one column.
> I would then like to add another list in a second column.
> Somehow they only appear as one long row. 
> Any feedback will be greatly appreciated. 
> 
> print "rain max values", rmax
> print "yearmonth", month year

'print' adds newline automatically.
More info:
http://docs.python.org/reference/simple_stmts.html#print

> OutputFolder=r"E:/test_out/"
> myfile=open(OutputFolder+'test.txt','w')
> myfile.write(str(monthyear))
> myfile.write(str(rmax))
> myfile.close()

'write' does not add newline. You need to add '\n' where you want new line.


-- 
shantanoo


More information about the Tutor mailing list