无涯教程-NumPy - center()函数

31 阅读1分钟

此函数返回所需宽度的数组,以使输入字符串居中并在左侧和右侧使用 fillchar 进行填充。

import numpy as np 
# np.char.center(arr, width,fillchar) 
print np.char.center(hello, 20,fillchar=*)

这是它的输出-

*******hello********

参考链接

www.learnfk.com/numpy/numpy…