0
点赞
收藏
分享

微信扫一扫

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 - 连接列表中的分隔符​​


举报

相关推荐

0 条评论