P40 string formatting

= #__author__ "Cool" 
#date = 2019/2/18 3:30



"" "
Author Format:
__author__ =" Cool "(name)
DATE = 2019/2/18 3:30

in ':' After passing an integer , ensures that the field has a width of at least so much for landscaping useful when the table:
>>> table = { 'Jack': 4127, 'Rose': 4098, 'Peter': 7678}
>>> for name, in table.items Phone ():
... Print ( '{0:10} ==> {. 1: 1Od}'. the format (name, Phone))
...
Peter ==> 7678
Rose ==> 4098
Jack ==> 4127

'' '



' ''
normal output
name = INPUT ( "the name:")
Age = INPUT ( "Age:")
Job = INPUT ( "the Job")
(Salary) the salary = INPUT ( "the salary:")

Print (name, Age, Job, the salary)

formatted output:% s
Placeholder%
% S = == correspondence string String S
% D == correspondence d = digit integer number
% f == correspondence f = float floating decimal
print ( "My name is S% "% (" Alfred.Xue "))



'' '

the Name = INPUT (" the Name: ")
Age = int (INPUT (" Age: "))
the Job = INPUT (" the Job: ")
the Salary = INPUT (" the salary: ")

IF Salary.isdigit (): # look like long numbers, for example: 100D, '200 is'
the Salary = int (the Salary)
the else:
Print (" INPUT digit for MUST ")
exit () # exit the program, exit () with brackets can things, Exit ( "INPUT digit for MUST")

MSG = '' '
-------- ----------- S% info of
the Name:% s
Age:% of
Job:% s
Salary:% d
Retired% in BE Will you years S
------------- End --------------
'' '% (the Name, the Name, Age, the Job, the Salary , 65-Age) # correspondence

Print (msg)


#digit translation: digital
# nretired (retirement age)
# tell the computer, followed by several variables, association, the association is one to one relationship

Guess you like

Origin www.cnblogs.com/Black-sail/p/11544110.html