教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 python中ljust什么意思

python中ljust什么意思

发布时间:2020-11-15   编辑:jiaochengji.com
教程集为您提供python中ljust什么意思等资源,欢迎您收藏本站,我们将为您提供最新的python中ljust什么意思资源

Python ljust()方法返回一个原字符串左对齐,并使用空格填充至指定长度的新字符串。如果指定的长度小于原字符串的长度则返回原字符串。

ljust()方法语法:

str.ljust(width[, fillchar])

参数

width -- 指定字符串长度。

fillchar -- 填充字符,默认为空格。

返回值

返回一个原字符串左对齐,并使用空格填充至指定长度的新字符串。如果指定的长度小于原字符串的长度则返回原字符串。

以下实例展示了ljust()的使用方法:

#!/usr/bin/python
str = "this is string example....wow!!!";
print str.ljust(50, '0');

以上实例输出结果如下:

this is string example....wow!!!000000000000000000

相关推荐:《Python教程》

以上就是python中ljust什么意思的详细内容,更多请关注教程集其它相关文章!

  • 本文原创发布教程集,转载请注明出处,感谢您的尊重!
  • 您可能感兴趣的文章:
    python中ljust什么意思
    python中的%是什么意思
    python中r代表什么意思
    python中转义字符是什么意思
    string在python中是什么意思
    python中divmod是什么意思
    python浮点数是什么意思
    python中num是什么意思
    python中的def语句是什么意思
    python中abs是什么意思

    [关闭]
    ~ ~