2014-10-18 15:44:07 -04:00
|
|
|
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 17:37:02 -05:00
|
|
|
|
|
|
|
# readinto() on writable file
|
2020-03-22 22:26:08 -04:00
|
|
|
f = open("io/data/file1", "ab")
|
2015-12-23 17:37:02 -05:00
|
|
|
try:
|
|
|
|
f.readinto(bytearray(4))
|
|
|
|
except OSError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("OSError")
|