Python Forum
Int.From_Bytes Method - Conversion of Non-Escaped Bytes Objects
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Int.From_Bytes Method - Conversion of Non-Escaped Bytes Objects
#1
Hello,

Sorry in advance for the likely basic nature of this question. I'm wondering how the "int.from_bytes" method returns the output that it does when it's converting input other than the escaped parts of bytes objects (see below for some examples).

These examples I understand - they're simply converting hexadecimals to decimal integers.

print(int.from_bytes(b'\x0f', "little"))
Output:
15
print(int.from_bytes(b'\xc0\xff\xee', "big"))
Output:
12648430
print(int.from_bytes(b'\xc0\xff\xee', "little"))
Output:
15663040
These examples I don't understand:

print(int.from_bytes(b'1', "big"))
Output:
49
print(int.from_bytes(b'Hello world', "big"))
Output:
87521618088882671231069284
print(int.from_bytes(b'Helloworld', "big"))
Output:
341881320660071462628452
Does it have something to do with the base system of the input and / or output - such as the particular base system the method assumes the input is expressed in? Or the base system it uses for the output? What am I missing here?

Thanks so much in advance for any help and have a great day.
Reply


Messages In This Thread
Int.From_Bytes Method - Conversion of Non-Escaped Bytes Objects - by new_coder_231013 - Jan-17-2024, 08:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Does XLRD have a method to extract embedded objects (pdf) from an excel sheet? matthewme 1 2,534 Jun-13-2019, 10:00 PM
Last Post: Larz60+
  replace bytes with other byte or bytes BigOldArt 1 10,699 Feb-02-2019, 11:00 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020