Python standard library: built-in function print (* objects, sep = & #39; & #39;, end = & #39; \ n & #39;, file = sys. stdout, flush = False), pythonsys. stdout

Source: Internet
Author: User

Python standard library: built-in function print (* objects, sep = '', end = '\ n', file = sys. stdout, flush = False), pythonsys. stdout

This function is used to format and output an object in a string representation to a stream file object file. All non-Keyword parameters are converted to string output in the str () mode. The keyword parameter sep is a delimiter. For example, if multiple parameters are output, you want to output intermediate separator characters; the keyword parameter end is the character at the end of the output. The default value is the line break \ n. the keyword parameter file is the file defining the stream output, which can be the standard system output sys. stdout can also be redefined as another file. The flush parameter immediately outputs the content to the stream file without caching it.

Example:

# Print () print (1, 2, 3, sep = ',', end = '\ r \ n') print (1, 2, 3, sep = '', end = '\ r \ n') with open (r 'C: \ abc1.txt', 'w') as demo: print (1, 2, 3, 88888888888, sep = ',', end = '\ n', file = demo)

The output is as follows:

1, 2, 3

 

1 2 3

In the abc1.txt file:

1, 2, 3, 888888888




Cai junsheng QQ: 9073204 Shenzhen

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.