方法一:
n = int((input(“请输入数字:”)))
print("*" * n)
for i in renge(n-2)
print("*" + " "* (n-2)+“*” )
print(“*”*n)方法二:
n = 5标签:renge,else,正方形,range,print,方法 From: https://www.cnblogs.com/luyi666/p/16862799.html
for i in range(n):
if i == 0 or i == n-1:
print("* " * n)
else:
print("* "+" "*(n-2)+"*")
方法三:
n = 5
for i in range(n):
if i == 0 or i == n-1:
print("* " * n)
else:
print("* "+" "*(n-2)+"*")