Skip to content

Instantly share code, notes, and snippets.

@dbwodlf3
Last active November 25, 2020 07:02
Show Gist options
  • Select an option

  • Save dbwodlf3/533accc79da4f21b789bb8258ed55776 to your computer and use it in GitHub Desktop.

Select an option

Save dbwodlf3/533accc79da4f21b789bb8258ed55776 to your computer and use it in GitHub Desktop.
Python 2 use struct instead of int.from_bytes
"""
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