您的位置:首页 > 编程语言 > Python开发

Python学习之列表和元组

2017-04-10 22:11 162 查看
序列(字符串)乘法示例

sentence = input('Sentence:')
screen_width = 80
text_width = len(sentence)
box_width = text_width + 4
left_margin = (screen_width - box_width)//2
print(' '*left_margin + '+' + '-'*(box_width-2) + '+')
print(' '*left_margin + '|' + ' '*(text_width+2) + '|')
print(' '*left_margin + '|' + ' ' + sentence + ' ' + '|')
print(' '*left_margin + '|' + ' '*(text_width+2) + '|')
print(' '*left_margin + '+' + '-'*(box_width-2) + '+')


结果输出:



(教材上示例有误)

未完待续……
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: