从而达到右对齐文本的目的。
3、center()方法用于使文本居中,而非左对齐或右对齐。...www.baidu.com/'
print("通过-实现左对齐", str1.ljust(30, '-'))
print("通过-实现左对齐", str2.ljust(30, '-'))
print("通过-实现右对齐...", str1.rjust(30, '-'))
print("通过-实现右对齐", str2.rjust(30, '-'))
print("通过-实现居中对齐", str1.center(30, '-'...))
print("通过-实现居中对齐", str2.center(30, '-'))
以上就是python字符串对齐的三种方法,希望对大家有所帮助。