About \ t horizontal tab horizontal tab (tab)

Source: Internet
Author: User

Today, when I was learning learn Python's hard-ex26, there was a question about \ t, and the following are the code and the output:

1 poem = "" "2 \tthe lovely world 3 with logic so firmly planted 4 cannot discern \ n the needs of love 5 nor comprehend \ t Passion from Intuition 6 and requires a explantion 7 \n\t\twhere there is none. 8 "" 9 print "--------------" Print poem13 print "--------------"
--------------The        lovely worldwith logic so firmly plantedcannot discern the needs of Lovenor comprehend  passion From Intuitionand requires a explantion                where there is none.--------------

As you can see, the second line of \ T and the seventh row of the two \ T are ' indented ' eight characters, and the seventh line of \ t only ' indent ' a character, then \ t is exactly how many characters (in fact, this is not true)?

To understand the problem, the code for the test is as follows:

1 print "" "2 123456789012345678901234567890123456789013 \t9\t789\t5\t\t14 1234567\t95 12345678\t76" ""

The number of the second line is to facilitate the calculation of the number of characters of the reference, run the result is as follows:

12345678901234567890123456789012345678901        9       789     5               11234567 912345678        7

You can see that Line3 's first three \ T are eight, seven, five characters, and Line4 Line5 are one and eight characters

Actually to here (although I also tested the other code, but I directly changed to the above code did not save, lazy again hit) can be roughly guessed, \ t should be eight characters for a loop, each \ t represents the current eight characters of the unit is OK, and then into the next string of eight characters of the unit

So line3 back two \ t should be indented seven and eight characters respectively, which can also explain the previous code \ t why only ' indent ' a character.

  Summarize:

\ t actually ends up representing the current eight-character unit and enters into the next eight-character cell.

About \ t horizontal tab horizontal tab (tab)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.