1 sentence = input("Sentence: ")
2
3 screen_width = 80
4 text_width = len(sentence)
5 box_width = text_width + 6
6 left_margin = int((screen_width - box_width) / 2)
7
8 print()
9 print(' ' * left_margin + '+' + '-' * (box_width-4) + '+')
10 print(' ' * left_margin + '| ' + ' ' * text_width + ' |')
11 print(' ' * left_margin + '| ' + sentence + ' |')
12 print(' ' * left_margin + '| ' + ' ' * text_width + ' |')
13 print(' ' * left_margin + '+' + '-' * (box_width-4) + '+')
14 print()
15
posted on 2013-05-12 15:28
unixfy 阅读(120)
评论(0) 编辑 收藏 引用