view raw
3zzy 3zzy - 10 months ago 41
Python Question

Export list as .txt (Python)

My Python module has a list that contains all the data I want to save as a .txt file somewhere. The list contains several tuples like so:

list = [ ('one', 'two', 'three'), ('four', 'five', 'six')]

How do I print the list so each tuple item is separated by a tab and each tuple is separated by a newline?


print '\n'.join('\t'.join(x) for x in L)