python two - the first set (the format)

Editor:

Python string formatting --format () method - learning makes me happy - CSDN blog
https://blog.csdn.net/i_chaoren/article/details/77922939

format

INPUT = S ( " Enter a string: " )
 Print ( " {:} * ^ 30 " .format (S))

Character length is less than 30

Enter a string: gsdfgsdfbgf
********* ********** gsdfgsdfbgf

Greater than or equal to 30 characters in length

Enter a string: skjdfkuasdgckjlshcdlkashdfiuaewhfiusarfh
skjdfkuasdgckjlshcdlkashdfiuaewhfiusarfh

A simple output

slightly

Second, the format of the control information

Parameter information {:} format control flag comprises: <filling> <alignment> <width> <type> field 6 <accuracy.>

 

 

the eval = S (INPUT ( " Enter a string: " ))
 Print ( " {: * 30 ^,} " .format (S))

Enter a string: 123123123
********* ********** 123,123,123

 

Guess you like

Origin www.cnblogs.com/uhduewifd/p/11203500.html