micropython/tests/io/file_readline.py

15 wiersze
255 B
Python
Czysty Zwykły widok Historia

f = open("data/file1")
print(f.readline())
print(f.readline(3))
print(f.readline(4))
print(f.readline(5))
print(f.readline())
2015-12-23 22:37:02 +00:00
# readline() on writable file
f = open("data/file1", "ab")
2015-12-23 22:37:02 +00:00
try:
f.readline()
except OSError:
print("OSError")
2015-12-23 22:37:02 +00:00
f.close()