string-formatting tag

2 questions


1 answers
114 views
0
I'd like to add a space on the right according to the length when printing.

To fill in the first 0: >>> print '%06d'%4'000004'This is what I know'hi 'How do I add spaces back together? str+*number I know we can write together.


1 answers
130 views
0
Python string format: %s.format()

The Python 2.6 introduced str.format() function seems to be somewhat different from how % is used. What is the best way to use it in what situation?The examples below are examples of each method, both...


© 2024 OneMinuteCode. All rights reserved.