numpy.core.defchararray.isspace(arr)
如果字符串中僅包含空格字符且至少包含一個字符,則函數對每個元素返回true,否則返回false。
用法: numpy.core.isspace(arr)
參數:
arr :str或unicode的數組。
返回:[ndarray]布爾輸出數組。
代碼1:
# Python program explaining
# numpy.char.isspace() method
import numpy as geek
# input arrays not containing any space
in_arr = geek.array([ 'Geeksforgeeks', 'Codechef'] )
print ("Input array:", in_arr)
out_arr = geek.char.isspace(in_arr)
print ("Output array:", out_arr)
輸出:
Input array: ['Geeksforgeeks' 'Codechef'] Output array: [False False]
代碼2:
# Python program explaining
# numpy.char.isspace() method
import numpy as geek
# input arrays containing string along with space
in_arr = geek.array([ 'Geeks\nfor\ngeeks', 'Code\tchef'] )
print ("Input array:", in_arr)
out_arr = geek.char.isspace(in_arr)
print ("Output array:", out_arr)
輸出:
Input array: ['Geeks\nfor\ngeeks' 'Code\tchef'] Output array: [False False]
代碼3:
# Python program explaining
# numpy.char.isspace() method
import numpy as geek
# input arrays containing only white space
in_arr = geek.array([ '\n', '\t', ' ', '\n\t '] )
print ("Input array:", in_arr)
out_arr = geek.char.isspace(in_arr)
print ("Output array:", out_arr)
輸出:
Input array: ['\n' '\t' ' ' '\n\t '] Output array: [ True True True True]
相關用法
- Numpy string less()用法及代碼示例
- Numpy string zfill()用法及代碼示例
- Numpy string isnumeric()用法及代碼示例
- Numpy string isdigit()用法及代碼示例
- Numpy string isdecimal()用法及代碼示例
- Numpy string isalpha()用法及代碼示例
- Numpy string swapcase()用法及代碼示例
- Numpy string split()用法及代碼示例
- Numpy string istitle()用法及代碼示例
- Numpy string isupper()用法及代碼示例
- Numpy string rsplit()用法及代碼示例
- Numpy string ljust()用法及代碼示例
- Numpy string islower()用法及代碼示例
- Numpy string upper()用法及代碼示例
- Numpy string title()用法及代碼示例
注:本文由純淨天空篩選整理自jana_sayantan大神的英文原創作品 numpy string operations | isspace() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。