Код: Выделить всё
def make_path(filename: os.PathLike) -> os.PathLike:
"""
Ensures that the directory for the given filename exists, creating it if necessary.
Args:
filename (os.PathLike): The path to the file for which the directory should be created.
Returns:
os.PathLike: The original filename.
"""
dirname = os.path.dirname(filename)
if dirname:
os.makedirs(os.path.dirname(filename), exist_ok=True)
return filename
< /code>
Но это дает ошибку для принятия строк, чего не произошло, когда у меня не было напечатано имя файла. < /p>
[b] Как Могу ли я правильно ввести имя файла
Подробнее здесь: https://stackoverflow.com/questions/794 ... th-dirname