views:

226

answers:

2

I receive strings in their hex format, i.e. s = "0x0ff" or s = "0fd" how can I check whether the above type of strings are null terminated or not? thanks!

+1  A: 

Try

s[-2:] == "00"
Adrian
fixed it, see above!
Adrian
A: 

Why would you care wether python strings are null terminated?

If you want to check wether the strings start by "0x" you can just use

x.startswith("0x")

as x cannot be located anywhere else in a hexstring.

Thomas Ahle
i receive it from socket...
bbb