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://codercto.com/courses/l/10.html
Developer's Guide to Social Programming
Mark D. Hawker / Addison-Wesley Professional / 2010-8-25 / USD 39.99
In The Developer's Guide to Social Programming, Mark Hawker shows developers how to build applications that integrate with the major social networking sites. Unlike competitive books that focus on a s......一起来看看 《Developer's Guide to Social Programming》 这本书的介绍吧!