NumPy islower()函数

原文:https://www.studytonight.com/numpy/numpy-islower-function

在本教程中,我们将介绍 Python 中 Numpy 库的 char 模块中的islower()函数。

如果输入字符串中的所有大小写字符都是小写的,并且至少有一个大小写字符,则 Numpy 库的islower()函数为每个元素返回 true。否则,此函数将返回 false。

  • 该函数以元素方式调用str.islower

  • 对于 8 位字符串,该函数是区域相关的。

islower()的语法:

使用该函数所需的语法如下:

numpy.char.islower(a)

上述语法表明islower()充电模块的函数,它采用单个参数。

在上面的语法中,参数a表示将应用该函数的字符串的输入数组。

返回值:

这个函数将返回一个布尔值的输出数组。

示例 1:使用字符串

在第一个例子中,我们将对单个字符串值应用islower()函数:

import numpy as np

string1 = "this is an apple"
x = np.char.islower(string1)
print("After applying islower() function:")
print(x)

应用 islower()函数后: 真

示例 2:使用字符串数组

代码片段如下,我们将在其中使用islower()函数:

import numpy as np

inp_ar = np.array(['studytonight', 'Online', 'portal']) 

print ("The input array : \n", inp_ar) 

output = np.char.islower(inp_ar) 
print ("The output array :\n", output)

输入数组: 【“StudyTonight”“在线”“入口”】 输出数组: 【真假真】

摘要

本教程是关于 Numpy 库的islower()函数的,该函数用于查找字符串是否为小写。