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

創(chuàng)新互聯(lián)建站公司2013年成立,先為鶴城等服務(wù)建站,鶴城等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為鶴城企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
寫一個(gè) Python 程序,用一個(gè)實(shí)例來(lái)檢查字符是否大寫。
使用映射函數(shù)檢查字符是否大寫的 Python 程序
在這個(gè) Python 示例中,我們使用 isupper 字符串函數(shù)來(lái)檢查給定字符是否大寫。
# Python Program to check character is Uppercase or not
ch = input("Please Enter Your Own Character : ")
if(ch.isupper()):
print("The Given Character ", ch, "is an Uppercase Alphabet")
else:
print("The Given Character ", ch, "is Not an Uppercase Alphabet")
Python 大寫字符或不輸出
Please Enter Your Own Character : I
The Given Character I is an Uppercase Alphabet
>>>
Please Enter Your Own Character : j
The Given Character j is Not an Uppercase Alphabet
Python 程序查找字符是否大寫
這個(gè) python 程序允許用戶輸入任何字符。接下來(lái),我們使用 If Else 語(yǔ)句來(lái)檢查用戶給定的字符是否大寫。這里, If 語(yǔ)句 (ch > = 'A '和 ch < = 'Z ')檢查字符是否大于等于 A,如果為 TRUE 則小于等于 Z,為大寫。否則,它不是大寫字符。
# Python Program to check character is Uppercase or not
ch = input("Please Enter Your Own Character : ")
if(ch >= 'A' and ch <= 'Z'):
print("The Given Character ", ch, "is an Uppercase Alphabet")
else:
print("The Given Character ", ch, "is Not an Uppercase Alphabet")
使用 ASCII 值驗(yàn)證字符是否大寫的 Python 程序
在這段 Python 代碼中,我們使用 ASCII 值來(lái)檢查字符是否大寫。
# Python Program to check character is Uppercase or not
ch = input("Please Enter Your Own Character : ")
if(ord(ch) >= 65 and ord(ch) <= 90):
print("The Given Character ", ch, "is an Uppercase Alphabet")
else:
print("The Given Character ", ch, "is Not an Uppercase Alphabet")
Please Enter Your Own Character : p
The Given Character p is Not an Uppercase Alphabet
>>>
Please Enter Your Own Character : T
The Given Character T is an Uppercase Alphabet 網(wǎng)站題目:Python程序:檢查字符是否大寫
文章轉(zhuǎn)載:http://fisionsoft.com.cn/article/coghjde.html


咨詢
建站咨詢
