bytearray.
data = bytearray(b"ABCDEF")
with open("bin.dat", "wb") as f:
f.write(data[1:4])
buf = bytearray(5)
with open("bin.dat", "rb") as f:
n = f.readinto(buf)
print(n, buf[:n].decode(), buf[3], len(buf))
What does the program print?Log in to join the discussion.
Loading…