I want to have real tabs in a print but \\t
only puts spaces.
Eg:
first:ThisIsLong second:Short
first:Short second:ThisIsLong
Instead of using tab (\t
), I suggest to use string formatting using printf-style formatting or str.format:
rows = [
['first:ThisIsLong', 'second:Short'],
['first:Short', 'second:ThisIsLong'],
['first:ThisIsEvenLonger', 'second:Short'],
]
for first, second in rows:
print('%-25s %s' % (first, second))
or
print('{:<25} {}'.format(first, second))