Last active
November 25, 2020 07:02
-
-
Save dbwodlf3/533accc79da4f21b789bb8258ed55776 to your computer and use it in GitHub Desktop.
Python 2 use struct instead of int.from_bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| docs: https://docs.python.org/2/library/struct.html#struct-format-strings. | |
| This example is just for using struct library instead of int.from_bytes. | |
| """ | |
| import struct | |
| bs1 = b'\xff\xff' | |
| bs2 = struct.unpack('<L', bs1)[0] | |
| print(bs2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment