31 - 让字符串居中显示

1. 如何让字符串居中显示,有哪些方法

  • center 方法
  • format 方法

2. 请使用center方法让字符串居中显示,两侧显示 ‘#’

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

32 - 连接列表中的分隔符

发布了131 篇原创文章 · 获赞 134 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_29339467/article/details/104413884
31
31)