新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:用python如何判斷字符的大小寫
python提供了isupper(),islower(),istitle()方法用來判斷字符串的大小寫。

創(chuàng)新互聯(lián)自2013年創(chuàng)立以來,先為石峰等服務(wù)建站,石峰等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為石峰企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
1、isupper()方法
Python isupper() 方法檢測字符串中所有的字母是否都為大寫。
示例:
str = "THIS IS STRING EXAMPLE....WOW!!!"; print str.isupper(); str = "THIS is string example....wow!!!"; print str.isupper();
輸出如下:
True
False
2、islower()方法
Python islower() 方法檢測字符串是否由小寫字母組成。
islower()方法語法:str.islower()
示例:
str = "THIS is string example....wow!!!"; print str.islower(); str = "this is string example....wow!!!"; print str.islower();
輸出如下:
False
True
3、istitle()方法
Python istitle() 方法檢測字符串中所有的單詞拼寫首字母是否為大寫,且其他字母為小寫。
istitle()方法語法:str.istitle()
示例:
str = "This Is String Example...Wow!!!"; print str.istitle(); str = "This is string example....wow!!!"; print str.istitle();
輸出如下:
True
False
分享標題:創(chuàng)新互聯(lián)Python教程:用python如何判斷字符的大小寫
標題鏈接:http://fisionsoft.com.cn/article/djppcgj.html


咨詢
建站咨詢
