例子

>>> s = "jihite"

>>> s.center(10, "*")
'**jihite**'

>>> s.ljust(10, "*")
'jihite****'

>>> s.rjust(10, "*")
'****jihite'

说明

center,ljust,rjust分别把字符串放在10个*的中央、靠左、靠右。注:字符窜要替换*的位置,如果超过*的个数,直接就没有*了,例如:

>>> s
'jihite'
>>> s.center(3, '*')
'jihite'

*

>>> 5 * '*'
'*****

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-10-02
  • 2022-01-16
  • 2022-02-07
  • 2021-08-19
  • 2022-12-23
猜你喜欢
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
相关资源
相似解决方案