The string str

# ### container type data (STR SET dict List tuple) 
 
# Type string STR ### 
"" "quotes to cause the data string" "" 
 
"" " 
# escape character: \ 
    (1) significant characters becomes meaningless 
    (2) becomes meaningless characters meaningful 
     
\ r \ n, \ n represents a newline 
\ t representative of indentation (horizontal tab) 
\ R & lt representative of the current drawn back character the first trekking 
 
can be used \ to meaningful quotes become meaningless 
. "" " 
 
 
# (1) single quotes 
strvar = 'I love you honey mushrooms cool' 
Print (strvar, of the type (strvar)) 
 
# (2) double quotes 
strvar = "night gave me black eyes, \ n but I use it rolling his eyes" 
strvar = "night gave me black eyes, \ t but I use it to turn \ r \ n supercilious" 
strvar = "night to I have a black eye, \ r but I use it rolling his eyes, " 
strvar =" night gave me a \ "black \" eyes " 
Print (strvar, of the type (strvar)) 
 
# (3) triple quotes (allows multi-line without having to single and double quotes escaped again) 
strvar = """I had no one, 
first.where" "" 
strvar = '' 'would have been "no" a' was', 
first.where' ''
Print (strvar) 
 
 
# ### yuan strings (strings output prototyping, failure to make an escape character) 
strvar = r "night gave me black eyes, \ r but I use it rolling his eyes" 
strvar = r "C : \ the Windows \ System32 \ Drivers \ etc " 
Print (strvar) 
 
# ### formatted string 
#% d% f% s" string% d "% (value) 
 
#% D integer placeholder 
strvar = "Xu Xinxin is a beauty in Guangdong, home to luxury cars car% d"% (10) 
#% 2d default number with the right 
strvar = "Xu Xinxin is a beauty in Guangdong, home% 2d car luxury car"% (3 ) 
#% -2d default number with left 
strvar = "Xu Xinxin is a beauty in Guangdong, home% -5d car luxury car"% (3) 
Print (strvar) 
 
 
#% f float placeholder (default after the decimal point reserved 6) 
strvar = "Lake used to be frustrating phone, revenue of RMB% f"% (9.99) 
#% .1f to rounding 
strvar = "Lake used to be tossing the phone, income% .3f dollars"% (9.99 ) 
Print (strvar) 
 
 
#% S string placeholder 
strvar = "% s"% ( " Shenzhen today by the rain.") 
Print (strvar) 
 
# Integrated Case
strvar = "Xiaocheng Yong,% .2f yuan a month, bought a% d doll, feeling the body% s"% (999.987,10, "squeezed dry") 
Print (strvar)

  

Guess you like

Origin www.cnblogs.com/eliwen/p/10967641.html