Recipe 1.4. Aligning Strings(Python Cookbook)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 >>> print '|', 'hej'.ljust(20), '|', 'hej'.rjust(20), '|', 'hej'.center(20), '|'
2 | hej | hej | hej |
3 >>> print 'hej'.center(2)
4 hej
5 >>> print 'hej'.center(20, '+')
6 ++++++++hej+++++++++
2 | hej | hej | hej |
3 >>> print 'hej'.center(2)
4 hej
5 >>> print 'hej'.center(20, '+')
6 ++++++++hej+++++++++