python矩形格式怎么打出来
可以使用字符串格式化来打印矩形,例如:
width = 10
height = 5
for i in range(height):
if i == 0 or i == height - 1:
# 打印顶部或底部边框
print('*' * width)
else:
# 打印中间部分
print('*' + ' ' * (width - 2) + '*')
输出:
**********
* *
* *
* *
**********
原文地址: https://www.cveoy.top/t/topic/fbzc 著作权归作者所有。请勿转载和采集!