python打印技巧
2021-03-30 09:25
标签:技巧 else size one img return com mic lse
python打印技巧 标签:技巧 else size one img return com mic lse 原文地址:https://www.cnblogs.com/dissipate/p/13584157.htmldef jar(b):
if not isinstance(b,int) or not b > 0:
print(‘inaccurate‘)
return None
vv=len(str(b))+1
for i in range(b):
for j in range(b-1,-1,-1):
if j i:
print(‘{:‘.format(j+1,vv),end=‘‘)
else:
print(‘ ‘*vv,end=‘‘)
print()
for i in range(b-1,-1,-1):
for j in range(b-1,-1,-1):
if j i:
print(‘{:‘.format(j+1,vv),end=‘‘)
else:
print(‘ ‘*vv,end=‘‘)
print()
def hum(b):
if not isinstance(b,(int,)) or not b > 0:
print(‘inaccurate‘)
tail=‘ ‘.join([str(b-v) for v in range(b)])
width=len(tail)
for p in range(b-1):
print(‘{:>{}}‘.format(‘ ‘.join([str(m+1) for m in range(p,-1,-1)]),width))
print(tail)
head=‘ ‘.join([str(b-v) for v in range(b)])
print(head)
for p in range(len(head)):
if head[p]==‘ ‘:
print(‘ ‘*p,head[p+1:])
hum(12)