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#############>