Python: Writing text with a width seperator? -


i looks this:

-----hello------ 

now know can symbols print defining , printing width, how insert text within it? thanks.

you should try this:

print 'hello'.center(16,'-') 

or this:

print '{:-^16}'.format("hello") 

that set width 16 , pad string '-'.

check tutorial here.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -