Ray's playground

 

Recipe 1.4. Aligning Strings(Python Cookbook)

align
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+++++++++

 

posted on 2010-12-18 11:09  Ray Z  阅读(163)  评论(0编辑  收藏  举报

导航