Python3 如何对字符串进行左、右、居中对齐
发布时间:2021-07-06 06:01:08 所属栏目:大数据 来源: https://blog.csdn.net/yilovex
导读:1. 使用 str 内置方法 In [1]: data = 'hello world!'In [2]: data.ljust(20)Out[2]: 'hello world! 'In [3]: data.rjust(20)Out[3]: ' hello world!'In [4]: data.center(20)Out[4]: ' hello world! ' 2. 使用 print 格式化处理 print 没有内置居中对齐的设
1. 使用
|