Python 程序:检查字符是否小写
创新互联python教程:

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、微信小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了陕州免费建站欢迎大家使用!
用一个实例编写一个 Python 程序来检查字符是否小写。
Python 程序使用 islower 函数检查字符是否为小写
在这个 Python 示例中,我们使用 islower 字符串函数来检查给定字符是否为小写。
# 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") 网页题目:Python 程序:检查字符是否小写
文章URL:http://www.jxjierui.cn/article/cdhhcjg.html


咨询
建站咨询
