micropython/tests/io/file_readinto.py

15 lines
276 B
Python
Raw Normal View History

b = bytearray(30)
f = open("io/data/file1", "rb")
print(f.readinto(b))
print(b)
f = open("io/data/file2", "rb")
print(f.readinto(b))
print(b)
2015-12-23 22:37:02 +00:00
# readinto() on writable file
f = open("io/data/file1", "ab")
2015-12-23 22:37:02 +00:00
try:
f.readinto(bytearray(4))
except OSError:
print("OSError")