# 如何对字符串进行左、中、右对齐 s = 'abc' print(s.ljust(20) + '|') print(s.ljust(20), '=') print(s.rjust(20)) print(s.center(20) + '|') # < 描述左对齐 # > 描述右对齐 # ^ 描述居中对齐 print(format(s, '^20')) d = { 'DistCull': 500.0, 'SmallCull': 0.04, 'farclip': 477, 'loadDist': 100.0, 'trilinear': 40 } print(d) num = max(map(len, d.keys())) print(num) for k in d: print(k.ljust(num) + ':' + str(d[k]))