python string as hex terminated with null
I receive strings in their hex开发者_JS百科 format, i.e. s = "0x0ff"
or s = "0fd"
how can I check whether the above type of strings are null terminated or not? thanks!
Try
s[-2:] == "00"
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.
精彩评论