Print! Print! Print !, Print

Source: Internet
Author: User

Print! Print! Print !, Print

Print statements can be printed, which is only an interface that is friendly to programmers for standard output streams.

Technically, this is to convert one or more objects into their text expressions and then send them to the standard output or another stream similar to a file.

In more detail, in Python, printing is closely linked to the concepts of files and streams.

File object Method

By default, print adds automatic formatting to the stdout stream. Unlike the file method, you do not need to convert an object to a string when using the print operation.

Standard output stream

The standard output stream (stdout) is only the default place for sending the text output of a program. With the standard input stream and error stream added, it is only one of the three data connections created when the script starts.

 

In Python 2.x, printing is a statement with its own specific syntax.

Print x, y print x, y, print> afile, x, y (send text to myfile. write)

In Python 3. X, printing is a built-in function that uses keyword parameters to represent a specific mode.

Print ([object,...] [, sep = ''] [, end = '\ n'] [, file = sys. stdout])

 

Print (X, Y) is equivalent

Import sys

Sys. stdout. write (str (X) + ''+ str (Y) + '\ n ')

It manually performs a String Conversion through str, adds a separator and a line break through "+", and calls the write method of the output stream.

 

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.