小册名称:Python合辑2-字符串常用方法
26、center()
返回一个原字符串居中,并使用空格填充至长度width的新字符串。
s = 'Python is awesome!'s = s.center(30, '-')print(s)# ------Python is awesome!------
s = 'Python is awesome!'
s = s.center(30, '-')
print(s)
# ------Python is awesome!------