码迷,mamicode.com
首页 > 编程语言 > 详细

47-python基础-python3-字符串-常用字符串方法(五)

时间:2019-08-17 20:02:28      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:inf   bsp   image   对齐   nbsp   python   填充   font   style   

6-rjust()、ljust()和 center()方法对齐文本

  • rjust()和 ljust()字符串方法返回调用它们的字符串的填充版本,默认通过插入空格来对齐文本。
  • rjust()和 ljust()方法的第二个可选参数将指定一个填充字符,取代空格字符。
  • center()字符串方法与 ljust()与 rjust()类似,但它让文本居中,而不是左对齐或右对齐。
实例1:
技术图片

实例2:

技术图片

实例3:

技术图片

 

47-python基础-python3-字符串-常用字符串方法(五)

标签:inf   bsp   image   对齐   nbsp   python   填充   font   style   

原文地址:https://www.cnblogs.com/summer1019/p/11369759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!