How to print blank lines in Python

Source: Internet
Author: User

In Python, when the code is long, want to see the code execution result in the Pycharm-console console or Python's own idle shell window, print some characters and so on, there are no line breaks between many lines affecting the viewing effect, so how to print a few lines of space in Python:

Three different ways:

1. Use line break "\ n":

1 Print " \n\n\n " 2 # The result is a 3 blank line

Or:

1 Print ' \ n ' 2 # 3 is three lines.

2. Use print directly, followed by no statements:

1 Print 2 Print 3 Print 4 # The result is a 3 blank line

3.for cycle (more trouble, not recommended)

1  for  in range (3):2     print'\ r'

Also, explain the difference between Python2 and Python3:

Python 2.x and 3.x output functions are different due to different versions

Use print output in version 2.x without parentheses using print output blank line

Use the print () output in the 3.x version with parentheses to output blank lines with print ()

Continuous output multiple lines can use the * number syntax

Use print ' \ n ' in the 2.x version #n为行数

Use print (' \ n ' * N) in the 3.x version #n为行数

Demo for version 3.5

1. Print #python2. x version, Python3 write print () to represent a blank line
2, of course, I write print ' \ n ' on behalf of a blank line, print ' \ n ' * 3 for printing three lines blank line
(Python3 version of parentheses, print (' \ n '))

How to print blank lines in Python

Related Article

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.