Format Print
1)%s: Represents a String
2)%d: Represents an integer
3)%f: Represents floating point number
1. Format Printing 1
Name = "Xiaoming" age = 29job = "IT" Print ("I am%s,age:%d,job:%s"% (name,age,job))
2. Format Printing 2
msg = ' Information of%s ' name:%s Age:%d job:%s '% (name,name,age,job) print (msg)
3. Remove the Blanks
Strip (...) method of Builtins.str instance S.strip ([chars]), str Return a copy of the string S with leading and trailing whitespace removed. # Remove the opening and trailing spaces of the string If chars is given and not None, remove characters in chars instead. Instance: name = "Xiaoming" age = 29job = "IT" name = Name.strip () print ("I am%s,age:%d,job:%s"% (name,age,job))
This article is from the "guoxianqi2016" blog, make sure to keep this source http://guoxianqi2016.blog.51cto.com/11407620/1762197
Python basic data type-string