python輸出00,01,02或001,002,003等格式字符串

rjust() 方法會返回一個原字符串右對齊,並使用空格填充至長度 width 的新字符串。若是指定的長度小於字符串的長度則返回原字符串python #!/usr/bin/env python3 #-*- coding:utf-8 -*- for i in range(1,30): print (str(i).rjust(2,'0')) 注意:int格式的不支持使用rjust方法,能夠先用
相關文章
相關標籤/搜索