best way to remove leading zeros from a tuple like string
bruceg113355 at gmail.com
bruceg113355 at gmail.com
Sun May 20 15:54:01 EDT 2018
Lets say I have the following tuple like string.
(128, 020, 008, 255)
What is the best way to to remove leading zeroes and end up with the following.
(128, 20, 8, 255) -- I do not care about spaces
This is the solution I came up with
s = "(128, 020, 008, 255)"
v = s.replace ("(", "")
v = v.replace (")", "")
vv = ",".join([str(int(i)) for i in v.split(",")])
final = "(" + vv + ")"
Thanks,
Bruce
More information about the Python-list
mailing list