python大小写转换

来源:互联网 发布:淘宝试用如何申请成功 编辑:程序博客网 时间:2024/05/24 05:01


1. upper

2. lower

>>> string="heLLO"
>>> string.upper()
'HELLO'
>>> string.lower()
'hello'
>>> string[0].upper()+string[1:].lower()
'Hello'

3. capitalize

>>> li = "this is a good cup!"
>>> li.capitalize()
'This is a good cup!'

4. title

>>> li = "this is a good cup!"

>>> li.title()
'This Is A Good Cup!'


0 0
原创粉丝点击