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是什么意思