21 lines
546 B
Python
21 lines
546 B
Python
|
|
import os
|
||
|
|
|
||
|
|
def read_file(file_path: str) -> str:
|
||
|
|
"""
|
||
|
|
Читает содержимое файла.
|
||
|
|
"""
|
||
|
|
with open(file_path, "r") as f:
|
||
|
|
return f.read()
|
||
|
|
|
||
|
|
def write_file(file_path: str, content: str):
|
||
|
|
"""
|
||
|
|
Записывает содержимое в файл.
|
||
|
|
"""
|
||
|
|
with open(file_path, "w", encoding="utf-8") as f:
|
||
|
|
f.write(content)
|
||
|
|
|
||
|
|
def create_directory(path: str):
|
||
|
|
"""
|
||
|
|
Создает директорию, если она не существует.
|
||
|
|
"""
|
||
|
|
os.makedirs(path, exist_ok=True)
|