C
cjl
Hey all:
I want to convert strings (ex. '3', '32') to strings with left padded
zeroes (ex. '003', '032'), so I tried this:
string1 = '32'
string2 = "%03s" % (string1)
print string2
This doesn't work. If I cast string1 as an int it works:
string1 = '32'
int2 = "%03d" % (int(string1))
print int2
Of course, I need to cast the result back to a string to use it. Why
doesn't the first example work?
-cjl
I want to convert strings (ex. '3', '32') to strings with left padded
zeroes (ex. '003', '032'), so I tried this:
string1 = '32'
string2 = "%03s" % (string1)
print string2
This doesn't work. If I cast string1 as an int it works:
string1 = '32'
int2 = "%03d" % (int(string1))
print int2
Of course, I need to cast the result back to a string to use it. Why
doesn't the first example work?
-cjl