- 用for实现
print('九九乘法表'.center(66,'-').center(68,'+')) #定义边框
for i in range(1,10):
print('|',end='')
for j in range(1,i+1):
print(j,'*',i,'=',j*i,'\t',end='',sep='')
print(' '*8*(9-i)+'|')
print('+'+'-'*71+'+') #定义边框
- 用while实现
i=1
while i<10:
j=1
while j<=i:
print(f"{j}*{i}={i*j}",end=' ')
j+=1
print()
i+=1