posts - 183,  comments - 10,  trackbacks - 0
Box
 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 阅读(115) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理