【原】Python 用例:打印一个 Header Box

 

 

sentence= input("Input Sentence: ")

screen_width=80
text_width= len(sentence)
box_width= text_width +2
left_margin= (screen_width - box_width)//2

print ('')
print (' '*left_margin + '+'+'-'*(box_width-2) + '+')
print (' '*left_margin + '|'+' '*text_width    + '|')
print (' '*left_margin + '|'+    sentence      + '|')
print (' '*left_margin + '|'+' '*text_width    + '|')
print (' '*left_margin + '+'+'-'*(box_width-2) + '+')

 

posted @ 2013-09-23 13:53  Tony Zhao  阅读(294)  评论(0编辑  收藏  举报