NUM = 15
def printLine(lineList):
lineList = [str(tmpNum) for tmpNum in lineList]
#print lineList
#print("%s%s" % (" " * (NUM - len(lineList)), " ".join(lineList)))
print " ".join(lineList).center(100) #关键是这个地方的输出对齐 我是指定了100的长度的居中对齐
for i in range(NUM):
if i < 2:
yhList = [1] * (i + 1)
else:
yhList[1:-1] = [(tmpNum + yhList[j]) for j, tmpNum in enumerate(yhList[1:])]
printLine(yhList)