>>> repr(tuple(int(i) for i in s[1:-1].split(',')))
'(128, 20, 8, 255, -1203, 1, 0, -123)'

2018-05-21 4:26 GMT-03:00 Peter Otten <__pete...@web.de>:

> bruceg113...@gmail.com wrote:
>
> > Looking over the responses, I modified my original code as follows:
> >
> >>>> s = "(0000128, 020, 008, 255, -1203,01,-000, -0123)"
> >>>> ",".join([str(int(i)) for i in s[1:-1].split(",")])
> > '128,20,8,255,-1203,1,0,-123'
>
> I think this looks better with a generator instead of the listcomp:
>
> >>> ",".join(str(int(i)) for i in s[1:-1].split(","))
> '128,20,8,255,-1203,1,0,-123'
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to