python提供了isupper(),islower(),istitle()方法用来判断字符串的大小写,具体实例如下:
>>> str_1 = "HELLO PYTHON" # 全大写 >>> str_2 = "Hello PYTHON" # 大小写混合 >>> str_3 = "Hello Python" # 单词首字母大写 >>> str_4 = "hello python" # 全小写
isupper() 判断是否全是大写
>>> str_1.isupper() True >>> str_2.isupper() False >>> str_3.isupper() False >>> str_4.isupper() False
相关推荐:《Python入门教程》
islower() 判断是否全是小写
>>> str_1.islower() False >>> str_2.islower() False >>> str_3.islower() False >>> str_4.islower() True
istitle() 判断首字母是否大写,其余的是否小写
>>> str_1.istitle() False >>> str_2.istitle() False >>> str_3.istitle() True >>> str_4.istitle() False
本文题目:创新互联Python教程:python怎么判断大小写
转载源于:http://www.shufengxianlan.com/qtweb/news34/418384.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联