Python及其应用程序中的isupper(),islower(),lower(),upper()
在本文中,我们将学习Python3.x中的isupper(),islower(),upper(),lower()函数。或更早。
这些是可用于字符串和相关类型的函数。它们包含在Python标准库中。
所有函数均不接受任何参数。isupper()和islower()返回布尔值,而upper()和lower()函数则返回大写或小写的字符串。
现在让我们看一个例子的实现
示例
string = 'tutorialspoint' # checking for uppercase characters print(string.isupper()) # checking for lowercase characters print(string.islower()) # convert to uppercase characters print(string.upper()) # convert to lowercase characters print(string.lower())
输出结果
False True TUTORIALSPOINT tutorialspoint
说明
如果传递了任何参数,解释器将引发错误。从输出中可以看出,所有字母都转换为所需的大小写。如果字符串包含任何整数或符号字符,则不会发生任何变化。
结论
在本文中,我们了解了Python3.x中的isupper(),islower(),lower()和upper()函数。或更早