新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python 程序:檢查字符是否小寫
創(chuàng)新互聯(lián)python教程:

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序開發(fā)、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了陜州免費建站歡迎大家使用!
用一個實例編寫一個 Python 程序來檢查字符是否小寫。
Python 程序使用 islower 函數(shù)檢查字符是否為小寫
在這個 Python 示例中,我們使用 islower 字符串函數(shù)來檢查給定字符是否為小寫。
# Python Program to check character is Lowercase or not
ch = input("Please Enter Your Own Character : ")
if(ch.islower()):
print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
print("The Given Character ", ch, "is Not a Lowercase Alphabet")Please Enter Your Own Character : k
The Given Character k is a Lowercase Alphabet
>>>
Please Enter Your Own Character : R
The Given Character R is Not a Lowercase AlphabetPython 程序查找字符是否小寫
這個 python 程序允許用戶輸入任何字符。接下來,我們使用 If Else 語句來檢查用戶給定的字符是否是小寫的。這里, If 語句檢查字符是否大于等于小 a,小于等于 z,如果是 TRUE,則小寫。否則,它不是小寫字符。
ch = input("Please Enter Your Own Character : ")
if(ch >= 'a' and ch <= 'z'):
print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
print("The Given Character ", ch, "is Not a Lowercase Alphabet")Please Enter Your Own Character : w
The Given Character w is a Lowercase Alphabet
>>>
Please Enter Your Own Character : Q
The Given Character Q is Not a Lowercase AlphabetPython 程序使用 ASCII 值驗證字符是否為小寫
在這個 Python 例子中,我們使用 ASCII 值來檢查字符是否小寫。
ch = input("Please Enter Your Own Character : ")
if(ord(ch) >= 97 and ord(ch) <= 122):
print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
print("The Given Character ", ch, "is Not a Lowercase Alphabet") 標(biāo)題名稱:Python 程序:檢查字符是否小寫
分享網(wǎng)址:http://www.fisionsoft.com.cn/article/cdhhcjg.html


咨詢
建站咨詢
