python - centering text using .format the right way? -


i want this:

============================= thread: 1 starting ============================== 

the way achieve .format method found is:

print("{:=^79}".format(' thread: ' + self.thread_id + ' starting ')) 

is there better way this? since bit hard read , kinda goes against whole .format principle of having string on left , values on right.

as @felix lahmer has pointed out, can use center:

>>> ' thread: {} starting '.format(42).center(79, '=') '============================= thread: 42 starting =============================' 

or nest format.

>>> '{:=^79}'.format(' thread: {} starting '.format(42)) '============================= thread: 42 starting =============================' 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -