您可以调查一下
str.ljust,
str.rjust我相信。
替代方法可能是使用format方法:
>>> '{:<30}'.format('left aligned')'left aligned '>>> '{:>30}'.format('right aligned')' right aligned'>>> '{:^30}'.format('centered')'centered'>>> '{:*^30}'.format('centered') # use '*' as a fill char'***********centered***********'


