跳到主要内容

Python String islower() 方法

islower() 的语法是:

string.islower()

islower() 参数

islower() 方法不接受任何参数。

islower() 的返回值

islower() 方法返回:

  • 如果字符串中存在的所有字母都是小写字母,则为 True。
  • 如果字符串包含至少一个大写字母,则为 False。

示例 1:islower() 的返回值

s = 'this is good'
print(s.islower())

s = 'th!s is a1so g00d'
print(s.islower())

s = 'this is Not good'
print(s.islower())

输出

True
True
False

示例 2:如何在程序中使用 islower()?

s = 'this is good'
if s.islower() == True:
print('不包含大写字母。')
else:
print('包含大写字母。')

s = 'this is Good'
if s.islower() == True:
print('不包含大写字母。')
else:
print('包含大写字母。')

输出

不包含大写字母。
包含大写字母。