Python's print statement

Source: Internet
Author: User

The print statement can output the specified text to the screen. For example, the output of ' Hello, world ', implemented in code as follows:

>>> print ' Hello, world '

Attention:

1. When we write code in a python interactive environment, >>> It is a prompt for the Python interpreter, not part of the code.

2. When we write code in a text editor, never add >>> yourself.

The print statement can also be followed by multiple strings, separated by a comma "," that can be connected to a string of outputs:

>>> print ' The quick brown fox ', ' Jumps over ', ' The lazy dog ' The quick brown fox jumps over the the lazy dog

Print prints each string sequentially, encounters a comma "," and outputs a space, so the output string is spelled like this:

Print also prints integers, or calculates the result:

>>> print 300300    #运行结果 >>> print + 200300    #运行结果

Therefore, we can print the results of the calculation 100 + 200 more beautifully:

>>> print ' + + = ', + 200100 + +-     #运行结果

Note: For the + 200,python interpreter automatically calculates the result 300, but, ' 100 + 200 = ' is a string rather than a mathematical formula, Python treats it as a string, please explain the above printing results yourself.

Python's print statement

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.