String formatting in Python

#String formatting: combine numbers and strings 
name =input( " Please enter name: " )
age =input( " Please enter the age: " ) #here is the string 
address =input( " Please enter the address: " )
msg1 = " My name is %s, age: %s, from %s " % (name,age,address)
msg = " My name is %s, age: %d, from %s " %( " Zhang Ermao " ,30, " Shanghai " ) #Note that %d is a placeholder for numbers

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325172084&siteId=291194637