Possible Duplicate:
Writing nicely formatted text in Python
I have this code for writting a header into the created txt file:
if not os.path.exists('list.txt'):
f= file('list.txt', 'w')
f.write ("\t".join("".join (str(row)) for row in header_names.keys()))+"\n")
f.write ("\n")
And this is the code I use to append new rows to the text file:
f = open("list.txt","a")
f.write ("\t".join("".join (str(row)) for row in header_names.values()))+"\n")
f.write ("\n")
f.close()
The output that get's written in the text file isn't as I want it do be:
Name some number some number2 % percentage average
Test 2 2 100.0 0.4
TestTestTest 3 4 75.0 0.49
tes 2 3 66.67 0.33
I would like something like this:
Name some number some number2 % percentage average
Test 2 2 100.0 0.4
Test 2 2 100.0 0.4
TestTestTest 3 4 75.0 0.49
tes 2 3 66.67 0.33
Is there any simple way to achieve this. It it's not mandatory it's written into the txt like that, but the output from reading should....