# n1记录" "的数量, n2记录"#"的数量, c记录层次(1,2,3,...7) def paint(n1,n2,c): #前三层 if c < 4: print(" "*n1+"#"*n2) return paint(n1-1,n2+2,c+1) # 后四层 elif 4<= c <=7: print(" "*n1+"#"*n2) return paint(n1+1, n2-2, c+1) paint(4, 1, 1)