String text alignment sh_18_

 

String text alignment sh_18_

# Assumptions: The following is captured from the network 
# requirement: sequence following output and center aligned 
POEM = [ " \ t \ n Deng Guanquelou " ,
          " the Audio " ,
          " sun mountains \ t \ n " ,
          " Yellow River flows into the sea " ,
          " for a grander sight " ,
          " higher level " ] 

for poem_str in the POEM: 

    # first remove whitespace characters in the string using the strip method 
    # then use the center to center text method 
    Print ( " |% S | " .% poem_str.strip () Center (10, " "))

 

Guess you like

Origin www.cnblogs.com/shaohan/p/11519384.html