NumPy 字符串函数 numpy.char.center() 此函数返回所需宽度的数组,使得输入字符串在左右两侧居中且填充 fillchar 。 import numpy as np # np.char.center(arr, width,fillchar) print np.char.center('hello', 20,fillchar = '*') PythonCopy 这是它的输出: *******hello******** PythonCopy