numpy.char.center()



This function returns an array of the required width so that the input string is centered and padded on the left and right with fillchar.

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

Here is its output −

*******hello********
numpy_string_functions.htm
Advertisements