I want to convert a number in python into a 3 character string, with prefix 0s. For example:
8 = "008" 12 = "012" 6 = "006" Thanks
My name is format. String format.
>>> '{:03d}'.format(7) '007' There is a build-in string method str.zfill(), examples:
>>> '12'.zfill(5) '00012' >>> '-3.14'.zfill(7) '-003.14' >>> '3.14159265359'.zfill(5) '3.14159265359'