在 Python3 中用前导零填充字符串
hour = 4
minute = 3
print("{:0>2}:{:0>2}".format(hour, minute))
print("{:0>3}:{:0>5}".format(hour, minute))
print("{:0<3}:{:0<5}".format(hour, minute))
print("{:$<3}:{:#<5}".format(hour, minute))
Output:
04:03
004:00003
400:30000
4$$:3####