Logical lines and physical lines

Source: Internet
Author: User

The physical line is what you see when you write the program. The logical line is a single statement that Python sees. Python assumes that each physical row corresponds to a
A logical line.
An example of a logical line is a statement like print ' Hello world '--if it is a line (as you see in the editor), it is also a physical line.
By default, Python wants to use only one statement per line, which makes the code easier to read.
If you want to use more than one logical line in a physical row, you need to use semicolons (;) to specifically indicate this usage. Semicolon

# For example:i = 5print  i# is the same as the following:i = 5; Print i; # It can also be written as: Print i; # can even be written as: Print I

It is strongly recommended that you persist in each physical line by writing only one line of logic. Just when the logical line is too long, write in more than one physical line
A logical line. This is to avoid using semicolons as much as possible, making the code easier to read. In fact, I have never been in Python
You have used or seen excessive numbers in the program.
Here is an example of writing a logical line in multiple physical rows. It is known as a clear row connection.

A polygon is an example of writing a logical line in multiple physical rows. It is known as a clear row connection.
' This is a string. This continues the string. ' Print   is a string. This continues the string. Similarly,print  i works the same as the following:print i
Sometimes, there is a hint of a hypothesis that can make you do not need to use backslashes. This situation occurs in logical lines using parentheses, Fang Kuo

or curly braces. This is referred to as the implied line connection. You'll see this usage in the sections that explain how to use the list later.

Logical lines and physical lines

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.