用Python制作网格

用Python制作网格,python,Python,如何指定默认值 r=int(input('Number of rows?: ')) c=int(input('Number of Columns?: ')) w=int(input('Width of a column')) h=int(input('Height of a row')) row= (('+')+ w*('-')+('+'))* (c) width= (('-') * w)*c col=(('+')+ w*('-')+('+')) height=(('|')+

如何指定默认值

r=int(input('Number of rows?: '))
c=int(input('Number of Columns?: '))
w=int(input('Width of a column'))
h=int(input('Height of a row'))  

row= (('+')+ w*('-')+('+'))* (c)   
width= (('-') * w)*c 
col=(('+')+ w*('-')+('+'))  
height=(('|')+ w * (' ')+ ('|'))* c

c=square brackets with zero in it

for i in range(r):
    print(row)
    print(height)

c.append(col)

print(c* square brackets having zero)
但它不起作用…[问题显示在上传的下图上]

以下是我对您的最佳猜测:

r = int(input('Number of rows?: ') or 4)
c = int(input('Number of Columns?: ') or 4)
w = int(input('Width of a column') or 4)
h = int(input('Height of a row') or 4)  

row = (('+') + w * ('-')) * (c) + '+'
width= (('-') * w) * c 
col = (('+') + w * ('-') + ('+'))  
height = (('|') + w * (' ')) * c + '|'

#c=square brackets with zero in it

for i in range(r):
    print(row)
    for j in range(h):
        print(height)
print(row)

#c.append(col)
#print(c* square brackets having zero)
和一个示例运行:

Number of rows?: 3
Number of Columns?: 4
Width of a column5
Height of a row6
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+

也许您可以提供一些示例输出,并澄清您试图用
c

上传的图像做什么?