I’m trying to figure out the number of bytes using this code as an example.
>>>print(len(b'x00x00'))
>>>2
>>># Although it should be 0
>>>print(len(b'x00x00x00x00x00x00x00x00'))
>>>8
>>># Although it should be 0
There is a method for int
that returns the correct value.
>>>print(int.from_bytes(b'x00x00'))
>>>0
>>># Although it should be 0
>>>print(int.from_bytes(b'x00x00x00x00x00x00x00x00'))
>>>0
>>># Although it should be 0
But still, why does len work this way?
New contributor
user26323648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.