How do I converted a null (0) terminated string to a Python string?

Richard Brodie R.Brodie at rl.ac.uk
Thu Sep 14 11:38:15 EDT 2006


"Marc 'BlackJack' Rintsch" <bj_666 at gmx.net> wrote in message 
news:pan.2006.09.14.15.36.07.509974 at gmx.net...

> I would spell it:
>
> if strg.endswith('\0'):
>    strg = strg[:-1]

I would just go with: strg = strg.rstrip('\0')





More information about the Python-list mailing list