OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

best way to remove leading zeros from a tuple like string


Am 21.05.2018 um 01:16 schrieb bruceg113355 at gmail.com:
> If I decide I need the parentheses, this works.
>
>>>> "(" + ",".join([str(int(i)) for i in s[1:-1].split(",")]) + ")"
> '(128,20,8,255,-1203,1,0,-123)'
>
> Thanks,
> Bruce

Creating the tuple seems to be even simpler.

 >>> str(tuple(map(int, s[1:-1].split(","))))
'(128, 20, 8, 255, -1203, 1, 0, -123)'

Wolfram