简体   繁体   中英

python string as hex terminated with null

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

尝试

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM