Created
February 8, 2020 08:33
-
-
Save shnhrtkyk/7e7b387f976d99db8af082b676dce021 to your computer and use it in GitHub Desktop.
pythonでバイナリを読む
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
| # -*- 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