开发者

python string as hex terminated with null

开发者 https://www.devze.com 2022-12-13 23:17 出处:网络
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

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

精彩评论

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