Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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!
s = "0x0ff"
s = "0fd"
0x0ff
Try
s[-2:] == "00"
Add a comment
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.
Required, but never shown
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.
Explore related questions
See similar questions with these tags.
0x0ffis 1 1/2 byte. I hope you get whole bytes.