# 示例代码:使用 rjust 函数
# rjust(width[, fillchar])
# width: 字符串的最小宽度
# fillchar: 填充字符,默认为空格
text = "hello"
result = text.rjust(10) # 使用默认填充字符(空格)
print(result) # 输出: ' hello'
result_with_fillchar = text.rjust(10, '*') # 使用指定填充字符(*)
print(result_with_fillchar) # 输出: '*****hello'
rjust
函数用于将字符串右对齐,并在左侧填充指定字符,直到字符串达到指定的宽度。上一篇:python reduce函数
下一篇:python config
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站