12345678910111213141516171819202122232425 |
- #!/usr/bin/env python3
- # 序列相加
- print([1, 2, 3, 4]+[6, 7, 8, 9]) # [1,2,3,4,5,6,7,8,9]
- # 乘法
- print([42]*10) # [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]
- # None、空列表和初始化
- sentence = input("Sentence: ")
- screen_width = 80
- text_width = len(sentence)
- box_width = text_width + 6
- left_margin = (screen_width - box_width) // 2
- print(left_margin)
- 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) + '+')
- print()
|