>>>PRint 'just to test it'.upper() #所有字母都转换成大写 >>>JUST TO TEST IT >>>print 'JUST TO TEST IT'.lower() #所有字母都转换成小写 >>>just to test it
2. 对字符串中的字符(仅对字母有效)部分大小写转换:
>>>print 'JUST TO TEST IT'.capitalize() #字符串的首字母转换成大写, 其余转换成小写 >>>Just to test it >>>print 'JUST TO TEST IT'.title() #字符串中所有单词的首字母转换成大写, 其余转换成小写 >>>Just To Test It
3. 判断字符串大小写函数:
>>>print 'JUST TO TEST IT'.isupper() >>>True >>>print 'JUST TO TEST IT'.islower() >>>False >>>print 'JUST TO TEST IT'.istitle() >>>False