Line breaks and tab __python in a Python string

Source: Internet
Author: User

questions about wrapping lines

First, ask a question, as follows.

The Python program code is as follows:

   

The output from the previous line of code is as follows:

I ' m Bob. What ' s your name?

The output above does not wrap. To wrap the line before what, the effect is:

I ' m Bob.
What ' s your name?

What to do.

Hit the carriage return before what, OK. No, the effect of this carriage return is the statement wrapping, not the output line wrapping. solutions with line breaks

The solution to the above problem is to insert a line break before what. The wording is:

   Print ("I ' m bob.\nwhat ' s your name?")


Tabs

Tabs also belong to the case where the "writing is a combination of two characters, but the meaning is only one character". It is written as "T", a combination of backslashes and T-letters, and T takes the meaning of a table. It means a character, called a tab. Its role is to align the columns of tabular data. Run the following code and you should understand what a tab character is.

#制表符的写法是 \ t, the action is to align the columns of the table.
Print ("School number \ t name \ t language \ t math \ t English")
Print ("2017001\t Cao \t99\t\t88\t\t0")
Print ("2017002\t Zhou Yu \t92\t\t45\t\t93")
Print ("2017008\t huanggai \t77\t\t82\t\t100")

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.