Skip to content

Instantly share code, notes, and snippets.

@shnhrtkyk
Created February 8, 2020 08:33
Show Gist options
  • Save shnhrtkyk/7e7b387f976d99db8af082b676dce021 to your computer and use it in GitHub Desktop.
Save shnhrtkyk/7e7b387f976d99db8af082b676dce021 to your computer and use it in GitHub Desktop.
pythonでバイナリを読む
# -*- coding: utf-8 -*-
"""
@author: shnhrtkyk
"""
path = "path/to/bin"
with open(path, mode='rb') as fin:
content = fin.read()
# print(content)
pass
for i in range(len(content)):
print (content[i:i+4])#4バイトずつ読みたいとき
val = int.from_bytes(content[i:i+4], 'little')
print (val)
i+=4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment