center_string 函数
在文本两侧补入字符,使文本位于指定宽度的中间。
语法
Center(text, width)Center(text, width, fill)center_string(text, width, fill)
参数与选项
text | 文本值,通常写在引号中。 |
|---|---|
width | 目标文本宽度;小于当前长度时原样返回。 |
fill | 可选的单字符填充文本;省略时使用空格。 |
示例
- 居中文本
Center('abc', 8, '-')返回 --abc---。
在文本两侧补入字符,使文本位于指定宽度的中间。
Center(text, width)Center(text, width, fill)center_string(text, width, fill)text | 文本值,通常写在引号中。 |
|---|---|
width | 目标文本宽度;小于当前长度时原样返回。 |
fill | 可选的单字符填充文本;省略时使用空格。 |
Center('abc', 8, '-')返回 --abc---。