使用format()
內(nèi)容左側(cè)填充對(duì)齊,format(‘string’,‘*>10’)
表示在字符串‘string’左側(cè)填充‘*’使填充后字符串總長(zhǎng)度為10
效果:****string
內(nèi)容右側(cè)填充對(duì)齊,format(‘string’,‘*<10’)
表示在字符串‘string’右側(cè)填充‘*’使填充后字符串總長(zhǎng)度為10
效果:string****
內(nèi)容兩側(cè)側(cè)填充對(duì)齊,format(‘string’,‘*^10’)
表示在字符串‘string’兩側(cè)填充‘*’使填充后字符串總長(zhǎng)度為10
效果:**string**