AI智能
改变未来

Lesson13——NumPy 字符串函数之 Par2:字符串比较函数


NumPy 教程目录

1 字符串比较函数

1.1 numpy.char.equal()

  

char.equal(x1, x2)

判断

x1 == x2

是否是真的。

Example:

print(np.char.equal(\'Blair\',\'blair\'))print(np.char.equal(\'Blair\',\'Blair\'))\"\"\"FalseTrue\"\"\"

1.2 numpy.char.not_equal()

  

char.not_equal(x1, x2)

判断

x1 == x2

是否不是真的。

Example:

print(np.char.not_equal(\'Blair\',\'blair\'))print(np.char.not_equal(\'Blair\',\'Blair\'))\"\"\"TrueFalse\"\"\"

1.3 numpy.char.greater_equal()

  

char.greater_equal(x1, x2)

判断

(x1 >= x2)

Example:

print(np.char.greater_equal(\'Blair\',\'blair\'))print(np.char.greater_equal(\'Blair\',\'Blair\'))print(np.char.greater_equal(\'abc\',\'abd\'))print(np.char.greater_equal(\'abc\',\'Abd\'))\"\"\"FalseTrueFalseTrue\"\"\"

1.4 numpy.char.less_equal()

  

char.less_equal(x1, x2)

判断

(x1 <= x2)

Example:

print(np.char.less_equal(\'Blair\',\'blair\'))print(np.char.less_equal(\'Blair\',\'Blair\'))print(np.char.less_equal(\'abc\',\'abd\'))print(np.char.less_equal(\'abc\',\'Abd\'))\"\"\"TrueTrueTrueFalse\"\"\"

1.5 numpy.char.less()

  

char.less(x1, x2)

判断

(x1 < x2)

Example:

print(np.char.less(\'Blair\',\'blair\'))print(np.char.less(\'Blair\',\'Blair\'))print(np.char.less(\'abc\',\'abd\'))print(np.char.less(\'abc\',\'Abd\'))\"\"\"TrueFalseTrueFalse\"\"\"

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Lesson13——NumPy 字符串函数之 Par2:字符串比较函数