开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜