掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
創(chuàng)新互聯(lián)Python教程:

為靜海等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及靜海網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、靜海網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
寫一個 Python 程序,通過一個實例,使用 islower 和 isupper 檢查字符是小寫還是大寫。
在這個 Python 示例中,我們使用 islower 和 isupper 字符串函數(shù)來檢查給定字符是小寫還是大寫。
# Python Program to check character is Lowercase or Uppercase
ch = input("Please Enter Your Own Character : ")
if(ch.isupper()):
print("The Given Character ", ch, "is an Uppercase Alphabet")
elif(ch.islower()):
print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
print("The Given Character ", ch, "is Not a Lower or Uppercase Alphabet")
這個 python 程序允許用戶輸入任何字符。接下來,我們使用 Elif 語句來檢查用戶給定的字符是小寫還是大寫。
# Python Program to check character is Lowercase or Uppercase
ch = input("Please Enter Your Own Character : ")
if(ch >= 'A' and ch <= 'Z'):
print("The Given Character ", ch, "is an Uppercase Alphabet")
elif(ch >= 'a' and ch <= 'z'):
print("The Given Character ", ch, "is a Lowercase Alphabet")
else:
print("The Given Character ", ch, "is Not a Lower or Uppercase Alphabet")
Python 字符是小寫還是大寫輸出
Please Enter Your Own Character : #
The Given Character # is Not a Lower or Uppercase Alphabet
>>>
Please Enter Your Own Character : T
The Given Character T is an Uppercase Alphabet
>>>
Please Enter Your Own Character : g
The Given Character g is a Lowercase Alphabet
在這段 Python 代碼中,我們使用 ASCII 值來檢查字符是大寫還是小寫。
ch = input("Please Enter Your Own Character : ")
if(ord(ch) >= 65 and ord(ch) <= 90):
print("The Given Character ", ch, "is an Uppercase Alphabet")
elif(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 Lower or Uppercase Alphabet")
Please Enter Your Own Character : o
The Given Character o is a Lowercase Alphabet
>>>
Please Enter Your Own Character : R
The Given Character R is an Uppercase Alphabet
>>>
Please Enter Your Own Character : $
The Given Character $ is Not a Lower or Uppercase Alphabet 
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流