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

Steve Holden steve at holdenweb.com
Thu Sep 14 05:51:28 CEST 2006


Michael wrote:
> Hi All,
> 
> I've received (via UDP) a null terminated string and need to convert it
> into a Python string. Can anyone tell me how this is done? If it helps,
> I know the number of characters in the string.
> 
> Thanks,
> M. McDonnell
> 
Have you received this string in Python or in C? If the former, then 
just throw away the last character of the string you've received and 
you're done!

s = s[:-1]

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list