该函数为数组中的每个元素调用 str.encode函数,默认编码为utf_8,可以使用标准Python库中可用的编解码器。

import numpy as np 
a=np.char.encode('hello', 'cp500') 
print a

其输出如下-

�����

参考链接

https://www.learnfk.com/numpy/numpy-char-encode.html