python大小写转换

来源:互联网 发布:淘宝怎么看店家vip 编辑:程序博客网 时间:2024/05/22 02:23

将字符转换为大写

使用upper()函数可以将字符串中所有的字符转换为大写

>>>'python'.upper()'PYTHON'

将字符串的首字母转换为大写,其余为小写

>>>'python Is FUN'.capitalzie()\'Python is fun'

将字符串所有单词的首字母转换为大写

>>>'pyThon IS FUN'.title()'Python Is Fun'

将字母转换为小写

使用lower()函数将字符串中的所有字符转化为小写

>>>'PYTHON IS FUN'.lower()'python is fun'

判断字符串是大写还是小写

判断大写使用isupper()函数

>>>'python'.isupper()False

判断小写使用islower()函数

>>>'python'.islower()True
0 0