1

Suppose I want to write "welcome" TAB "username" in file. How can I specify this TAB?

f = open(filename, 'w')
f.write("welcome:"+TAB+"username");
Sagar Bhosale
  • 307
  • 3
  • 19

2 Answers2

3

Use \t character:

>>> print('\tsomething')
    something

In your case that would be

f.write("welcome:\tusername")
vaultah
  • 40,483
  • 12
  • 109
  • 137
  • Just for sake of completeness, you can also use `chr(9)`, `9` being the ASCII code of the `TAB` character. – svvac Jun 19 '14 at 06:49
1

Just:

f.write("welcome:\tusername")
Juan Diego Godoy Robles
  • 13,642
  • 2
  • 42
  • 51