当前位置: 首页 > 文档资料 > NumPy 中文教程 >

center()

优质
小牛编辑
132浏览
2023-12-01

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

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

这是它的输出 -

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