Python3 ljust()方法
Python 3 教程
· 2019-02-06 05:59:19
描述
ljust() 方法返回一个原字符串左对齐,并使用空格填充至指定长度的新字符串。如果指定的长度小于原字符串的长度则返回原字符串。
语法
ljust()方法语法:
str.ljust(width[, fillchar])
参数
- width -- 指定字符串长度。
- fillchar -- 填充字符,默认为空格。
返回值
返回一个原字符串左对齐,并使用空格填充至指定长度的新字符串。如果指定的长度小于原字符串的长度则返回原字符串。
实例
以下实例展示了ljust()的使用方法:
#!/usr/bin/python3 str = "Codercto example....wow!!!" print (str.ljust(50, '*'))
以上实例输出结果如下:
Codercto example....wow!!!**************************
点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html
Big Java Late Objects
Horstmann, Cay S. / 2012-2 / 896.00元
The introductory programming course is difficult. Many students fail to succeed or have trouble in the course because they don't understand the material and do not practice programming sufficiently. ......一起来看看 《Big Java Late Objects》 这本书的介绍吧!