python center() 函数

 

center

Python center() 返回一个原字符串居中,并使用空格填充至长度 width 的新字符串。默认填充字符为空格。

语法

center()方法语法:

str.center(width[, fillchar])

参数

  • width -- 字符串的总宽度。
  • fillchar -- 填充字符。
>>> name = "mike"
>>> name.center(40,"-")


'------------------mike------------------'
>>>

 

posted @ 2018-01-18 14:58  minger_lcm  阅读(1236)  评论(0编辑  收藏  举报