LoginSignup
0
1

More than 1 year has passed since last update.

Pythonエンディアン変換

Posted at
python
#整数読み込み
num = 9240
#16進変換(0x除く)
num_hex = hex(num)[2:]
#16進→バイト変換
bytes_be = bytes.fromhex(num_hex)
#エンディアン変換
bytes_le = bytes_be[::-1]
hex_le = bytes_le.hex()
print(hex_le)  # "1824"
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1