tplt = "{0:{3}^10}\t{1:{3}^10}\t{2:^10}" print(tplt.format("学校名称", "位置", "分数", chr(12288)))
{3} 对应的中文空格chr(1228)
:次序与宽度分割符
^ 代表居中
10表示宽度
tplt = "{0:{3}^10}\t{1:{3}^10}\t{2:^10}" print(tplt.format("学校名称", "位置", "分数", chr(12288)))
{3} 对应的中文空格chr(1228)
:次序与宽度分割符
^ 代表居中
10表示宽度
本文标题:[python]指定字符串宽度tab对齐
本文链接:https://www.haomeiwen.com/subject/kjcrwltx.html
网友评论