format占位符

while True:
    try:
        st = input()
        for i in range(0, len(st), 8):
            print(i)
            print("{0:1<8}".format(st[i:i + 8]))
    except:
        break

 

"{:18<}".format(st[i:i + 8]),这里0:一般是下标的表示方法,1是填充物,<是向右看齐,8是位数,就是format后面的数值不足八位如何填充的问题
posted @ 2022-09-08 11:22  年轻人——001  阅读(75)  评论(0编辑  收藏  举报