width = 11 #注意宽度必须位奇数
for i in range(-width//2,width//2+1):
prespace=i if i>0 else -i
print(' '*prespace+'*'*(width-prespace*2))
运行结果:
*
***
*****
*******
*********
***********
*********
*******
*****
***
*