无涯教程-Python - isupper()函数

160 阅读1分钟

Python isuper()检查字符串的所有基于大小写的字符(字母)是否都是大写的。

isupper() - 语法

str.isupper()

isupper() - 返回值

如果字符串中的所有大写字符都是大写的,并且至少有一个大写字符,则此方法返回true,否则返回false。

isupper() - 示例

下面的示例显示了isuper()方法的用法。

#!/usr/bin/python

str="THIS IS STRING EXAMPLE....WOW!!!"; print str.isupper()

str="THIS is string example....wow!!!"; print str.isupper()

当无涯教程运行上面的程序时,它产生以下输出-

True
False

参考链接

www.learnfk.com/python/stri…