場景:
字符串對齊
python提供非常容易的方法,使得字符串對齊
>>> print("abc".center (30,'-'))
-------------abc--------------
>>> print("abc".ljust (30)+'|')
abc |
>>> print("abc".rjust (30))
abc
>>>
分別是center,ljust,rjust
三個方法默認(rèn)填充是空格,也可以使用其他字符填充