How can I fill out a Python string with spaces?

I want to fill out a string with spaces. I know that the following works for zero's:

>>> print("'%06d'"%4)
'000004'

But what should I do when I want this?:

'hi    '

of course I can measure string length and do str+" "*leftover, but I'd like the shortest way.

← Назад к списку