【问题标题】:Python: A very simple star patterned boxPython:一个非常简单的星形盒子
【发布时间】:2021-12-02 07:19:07
【问题描述】:

我必须制作一个里面是空的盒子。 我想做一个看起来像这样的盒子:

+++
+ +
+++

宽度可以变化。这是我目前的代码。

width = int(input("Enter box size(3-30) >>>"))
top = "+" * width
middle = 
bottom = "+" * width

不知道在中间放什么。

【问题讨论】:

  • 中间 = "+" + " "*(width-2) + "+"

标签: python box


【解决方案1】:

由于中间是"+",后跟width - 2 空格,然后是另一个"+",因此您可以将中间设置为"+" + " " * (width - 2) + "+"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-21
    • 2015-09-28
    • 1970-01-01
    • 2013-08-16
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    • 2014-01-22
    相关资源
    最近更新 更多