2020-1-7

>>> string='  python    '
>>> string
'  python    '
>>> string.rstrip()
'  python'

>>> string.rstrip()
'  python'
>>> string.strip()
'python'
>>> string.lstrip()
'python'

>>> x = ' Albert Einstein once said, " A person who never made a mistake never tried anything new."'
>>> print(x)
 Albert Einstein once said, " A person who never made a mistake never tried anything new."

>>> x= 'albert einstein'
>>> x.title()
'Albert Einstein'

.reverse()

.sort()

.sorted()

.sort(reverse=True)

猜你喜欢

转载自www.cnblogs.com/flyme2moon/p/12161266.html