Create python string with fill char and counter
I'd like to do it in an elegant fashion:
>>> ''.zfill(5, '-')
'-----'
There's any way to initialize a string with a fill char and 开发者_Python百科a counter? Of course, count may vary.
Just try:
>>> '-'*5
'-----'
It's that simple in Python :)
The introduction to strings in the "official" tutorial says:
Strings can be concatenated (glued together) with the
+
operator, and repeated with*
精彩评论