学习笔记(16):Python 面试100讲(基于Python3.x)-让字符串居中显示

立即学习:https://edu.csdn.net/course/play/26755/340143?utm_source=blogtoedu

字符串居中:center 和format 方法

1、print('<' + 'hello'center(30) + '>')

print('<' + 'hello'center(30,'#') + '>')

2、print('<{:^30}>'.format('hello')

print('<{:#^30}>'.format('hello')

发布了26 篇原创文章 · 获赞 2 · 访问量 280

猜你喜欢

转载自blog.csdn.net/qq_35504363/article/details/104295622