有时遇到字串等宽格式化输出,记性不好又要上网花时间查,就先在此记下当个笔记!
未使用等宽格式化前:
print(line[:2].strip()+' '+CJCode+' '+getCJHead(CJCode))
输出结果:
使用等宽格式化后:
print(line[:2].strip()+' '+'{:5}'.format(CJCode)+' '+getCJHead(CJCode))
输出结果:
有时遇到字串等宽格式化输出,记性不好又要上网花时间查,就先在此记下当个笔记!
未使用等宽格式化前:
print(line[:2].strip()+' '+CJCode+' '+getCJHead(CJCode))
输出结果:
使用等宽格式化后:
print(line[:2].strip()+' '+'{:5}'.format(CJCode)+' '+getCJHead(CJCode))
输出结果: