S为一字符串,可以使用python的内建函数对S中的字母大小写做判断和改变。
supper,lower和capitalize是转换函数,可以把字符串中的字母做相应的处理。
istitle,isupper和islower是判断函数,它们对字符串做相应的判断,返回的True或者False。
- S.upper() #S中的字母大写
实例如下:
>>>S ="hello,world"
>>>S.upper()
'HELLO,WORLD'
- S.lower() #S中的字母小写
实例如下:
>>>S ="HELLO,world"
>>>S.lower()
'hello,world'
- S.capitalize() #首字母大写
实例如下:
>>>S ="hello,world"
>>>S.capitalize()
'Hello,world'
- S.istitle() #单词首字母是否大写的, 且其它为小写
实例如下:
>>>S="Hello"
>>>S.istitle()
True
>>>S="hEllo"
>>>S.istitle()
False
- S.isupper() #S中的字母是否全是大写
实例如下:
>>>S="wolD"
>>>s.isupper()
False
- S.islower() #S中的字母是否全是小写
实例如下:
>>>s.islower()
False
&spm=1001.2101.3001.5002&articleId=123610970&d=1&t=3&u=c53b0eac3f474fada39ebeb70f769775)
964

被折叠的 条评论
为什么被折叠?



