Created
July 9, 2018 12:02
-
-
Save Fhernd/844582a97c6d46a7b0b4d618db57ad15 to your computer and use it in GitHub Desktop.
Buffer mutable. OrtizOL.
This file contains 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
import os.path | |
def leer_buffer(archivo): | |
b = bytearray(os.path.getsize(archivo)) | |
with open(archivo, 'rb') as f: | |
f.readinto(b) | |
return b | |
with open('archivo.bin', 'wb') as f: | |
f.write(b'Homo Deus: una historia del manana') | |
b = leer_buffer('archivo.bin') | |
print(b) | |
print(b[0:4]) | |
print(len(b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment