Escape character \ t behaves differently with space

Why I see the output only if I put a space.

print "I love you %s" % "\tI'm tabbled in." print "I love you %s" % " \tI'm tabbled in." 

Output

 I love you I'm tabbled in. I love you I'm tabbled in. 
+6
source share
1 answer

As a rule, \ t (TAB) goes to the next tab - this is not a synonym for "n spaces".

  I love you XI'm tabbled in. I love you XXXXI'm tabbled in. 0---1---2---3---4--- 

The current terminal is configured with a freeze frame size 4, which is shown below. "X" are characters that are missing a tab.

So, the first line skips one character with a tab (it goes to tab 3), and the second line writes a space, and then skips four characters (to go to tab 4).

+12
source

Source: https://habr.com/ru/post/986627/


All Articles