1

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
  • 0x0ff is 1 1/2 byte. I hope you get whole bytes. Commented Dec 11, 2009 at 14:26

2 Answers 2

1

Try

s[-2:] == "00"
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.