How do I write a “tab” in Python?


Let's say I have a file. How do I write "hello" TAB "alex"?


Answers:


This is the code:

f = open(filename, 'w')
f.write("hello\talex")

The \t inside the string is the escape sequence for the horizontal tabulation.