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
  • 407
  • 1
  • 5
  • 19

2 Answers2

3

Use \t character:

>>> print('\tsomething')
    something

In your case that would be

f.write("welcome:\tusername")
vaultah
  • 44,105
  • 12
  • 114
  • 143
  • 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
  • 14,447
  • 2
  • 38
  • 52