ting = ''' +-- ReferenceError # 弱引用(Weak reference)试图访问已经垃圾回收了的对象 +-- RuntimeError # 一般的运行时错误 +-- SyntaxError # Python 语法错误 * +-- SystemError # 一般的解释器系统错误 +-- TypeError # 对类型无效的操作 +-- ValueError # 传入无效的参数 dddd +-- Warning # 警告的基 ''' # print(ting) def format_str(ting): ting2 = '' for i in ting.split(' '): if '#' in i: l, r = i.split('#') strr = '#'.join([str(l).ljust(38), r]) ting2 = ' '.join([ting2, strr]) else: ting2 = ' '.join([ting2, str(i)]) return ting2.strip() s = format_str(ting) print(s)