Fhernd icon

buffer-mutable.py

Fhernd | PRO | 07/09/18 12:02:24 PM UTC | 0 ⭐ | 2940 👁️ | Never ⏰ | []
Python |

330 B

|

None

|

0 👍

/

0 👎

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))

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎