Formatted output py

Source: Internet
Author: User

# Formatted Output
#% Placeholder data type: s string d: integer f: Floating-point R: Built-in function will talk about I ...
# The first way
# NAME = input (' Please enter name: ')
# age = input (' Please enter Ages: ')
# job = input (' Please enter work: ')
# hobby = input (' Please enter hobby: ')
#
# msg = " " "
#------------Info of%s-----------
# Name:%s
# Age:%d
# Job:%s
# Hobby:%s
#-------------End-----------------
# "" " % (name, name, int (age), job, hobby)
# Print (msg)

# The second way

# dic = {' name ': ' Jinyuan ', ' age ': ' Job ': ' IT ', ' hobby ': ' Man '}
#
# msg = " " "
#------------Info of% (name) s-----------
# Name:% (name) s
# Age:% (age) D
# Job:% (Job) s
# Hobby:% (Hobby) s
#-------------End-----------------
# "" " % dic
# Print (msg)

# in formatted output only want to simply represent% write percent
msg = ' My name is%s, this year%d, learning Progress 5% '% (' Jin Yuan ')
Print (msg)

# Summary: If you want to make a template for a string class, or if you want to make a string some location into dynamic input, then you think of string concatenation, formatted output.

Formatted output py

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.