# version 1
defread_file(path:str="example.txt")->None:file=open(file=path,mode="r",encoding="utf-8")data:str=file.read()print(data)# version 2
defread_file_with(path:str="example.txt")->None:withopen(file=path,mode="r",encoding="utf-8")asfile:data:str=file.read()print(data)read_file(path="example.txt")read_file_with(path="example.txt")
Обязательные cookie нужны для входа и настроек. Аналитику — Яндекс.Метрику без записи сеансов — включаем только с твоего согласия; отказ ничего не ломает, выбор можно изменить в подвале сайта.
Подробнее о cookieСогласие на аналитику