Default parameter of the print () function of python3.x

Source: Internet
Author: User

Default parameter of the print () function of python3.x
Python beginners, write a 99 multiplication table,

For I in range (1, 10): for j in range (1, I + 1): print (j, 'x', I, '= ', j * I, end = '\ t') print (' \ n ')

 

Here, end = '\ t' indicates that the end parameter is not added to the end of a TAB. Therefore, the line feed is automatically generated each time the end line is output and the second line is output.
>>> Help (print) Help on built-in function print in module builtins: print (...) print (value ,..., sep = '', end = '\ n', file = sys. stdout, flush = False) Prints the values to a stream, or to sys. stdout by default. optional keyword arguments: file: a file-like object (stream); defaults to the current sys. stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.

 

Sep indicates that the value and value are separated by spaces by default, and end indicates the default line feed at the end. In python2.X, you only need to add a comma after print.

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.