Python 字串等宽格式化输出

xiaoxiao2021-02-28  99

有时遇到字串等宽格式化输出,记性不好又要上网花时间查,就先在此记下当个笔记!

未使用等宽格式化前:

print(line[:2].strip()+' '+CJCode+' '+getCJHead(CJCode))

输出结果:

使用等宽格式化后:

print(line[:2].strip()+' '+'{:5}'.format(CJCode)+' '+getCJHead(CJCode))

输出结果:

转载请注明原文地址: https://www.6miu.com/read-57412.html

最新回复(0)