S.rjust(width[, fillchar])
其中各個引數的含義如下:S = 'http://c.biancheng.net/python/' addr = 'http://c.biancheng.net' print(S.rjust(35)) print(addr.rjust(35))輸出結果為:
http://c.biancheng.net/python/ http://c.biancheng.net可以看到,每行字串都占用 35 個位元組的位置,實現了整體的右對齊效果。
S = 'http://c.biancheng.net/python/' addr = 'http://c.biancheng.net' print(S.rjust(35,'-')) print(addr.rjust(35,'-'))輸出結果為:
-----http://c.biancheng.net/python/ -------------http://c.biancheng.net