Files & Dirs
Прочитати увесь файл
open / close
f = open('path_to/file.txt', mode)
text = f.read() # зчитує увесь файл в один великий рядок
f.close()
print(text) # 'first string\nsecond string\nthird string\n...'with
with open('path_to/file', mode) as f:
text = f.read()readlines
read + split
modes (режими)
Прочитати файл порядково
Приклад з виключенням
Робота с двомя файлами одночасно
Last updated