rjust() 返回一个原字符串右对齐,并使用空格填充至长度 width 的新字符串。如果指定的长度小于字符串的长度则返回原字符串。
rjust()方法语法:
str.rjust(width[, fillchar])
返回一个原字符串右对齐,并使用空格填充至长度 width 的新字符串。如果指定的长度小于字符串的长度则返回原字符串
以下实例展示了rjust()函数的使用方法:
#!/usr/bin/python3
str = "this is string example....wow!!!"
print (str.rjust(50, '*'))
以上实例输出结果如下:
******************this is string example....wow!!!
©2020 IT自习室京ICP备20010815号