How do I converted a null (0) terminated string to a Python string?
Michael
MichaelDMcDonnell at yahoo.com
Thu Sep 14 10:45:35 EDT 2006
John,
Since I'm new to Python, I'm having trouble understanding what this
means (see below). Would appreciate any help.
if strg[-1] == "\0":
strg = strg[:-1]
Thanks,
MDM
John Machin wrote:
> Fredrik Lundh wrote:
> > Michael wrote:
> >
> > > Thanks for your reply. Just wondering... how are Python strings
> > > formatted? Evidently they're not 0 terminated.
> >
> > have you tried *printing* the thing you got via UDP?
> >
> > to get a programmer-friendly representation of an arbitrary object, use
> >
> > print repr(obj)
> >
> > (where obj is your string, in this case).
> >
>
> Probably not; there was no indication after the two messages where I
> mentioned repr :-)
More information about the Python-list
mailing list