标签:python 居中
把字体显示在屏幕的中间
sentence = raw_input("Sentence:") screen_width = 80text_width = len(sentence)box_width = text_width + 6left_margin = (screen_width - box_width) // 2 printprint ‘ ‘*left_margin + ‘+‘ + ‘-‘*(box_width) + ‘+‘print ‘ ‘*(left_margin+2) + ‘| ‘ + ‘ ‘*text_width + ‘ |‘print ‘ ‘*(left_margin+2) + ‘| ‘ + sentence + ‘ |‘print ‘ ‘*(left_margin+2) + ‘| ‘ + ‘ ‘*text_width + ‘ |‘print ‘ ‘*left_margin + ‘+‘ + ‘-‘*(box_width) + ‘+‘
简单地定义了屏幕的宽度,没有去取实际值,后面在更新
本文出自 “不然嘞” 博客,请务必保留此出处http://buranle.blog.51cto.com/8870751/1639536
标签:python 居中
原文地址:http://buranle.blog.51cto.com/8870751/1639536