首页 > 编程语言 > 详细

python center, ljust, rjust

时间:2016-04-16 20:55:46      阅读:273      评论:0      收藏:0      [点我收藏+]

例子

>>> 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 * *
*****

 

python center, ljust, rjust

原文:http://www.cnblogs.com/kaituorensheng/p/5399064.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!