Python formatted output

Source: Internet
Author: User

Python formatted output:

    1.

Print (' Your best friend is '%s ' computer ')

%d formatted output integer

%s formatted output string

%r format output pre-unknown type, any type

Print (' Your best%s is%s '% (' friends ', ' computer ')

      Pit point:

1. The percent semicolon does not distinguish between Chinese and English

2. () parentheses to be entered in English form

3. Quotation marks should be in English form

    2. 

Name = input (' Please enter your name: ')

       Age =int ((Input (' Please enter your Ages: ')))
scholar = input (' Educational background: ')
info = "' #格式化输出然后交给info
+++++++++++ {_name} related information +++++++++++
name: {_name}
Age: {_age} years
Education background: {_scholar}
+++++++++++ Info ++++++++++++++++++
". Format (_name =name, _age = age, _scholar = scholar) #格式化输出, each corresponding to the corresponding value, can disrupt
Print (info)
print (' Goodbye ')

      Pit point:
1. The "content" semicolon can also be placed on the left side of the assignment equal sign to make long formatted output
Starting and ending formats
2.format formatted output method {} can write a name or do not write, or preferably write, or
May not know how to die, do not fill in order to fill in the corresponding position

Python formatted output

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.