[Python]#5 Path

Clay Ryu's sound lab·2023년 7월 28일
0

Framework

목록 보기
19/49

Path.mkdir()

Path.mkdir(mode=0o777, parents=False, exist_ok=False)
Create a new directory at this given path. If mode is given, it is combined with the process’ umask value to determine the file mode and access flags. If the path already exists, FileExistsError is raised.

If parents is true, any missing parents of this path are created as needed; they are created with the default permissions without taking mode into account (mimicking the POSIX mkdir -p command).

If parents is false (the default), a missing parent raises FileNotFoundError.

If exist_ok is false (the default), FileExistsError is raised if the target directory already exists.

If exist_ok is true, FileExistsError exceptions will be ignored (same behavior as the POSIX mkdir -p command), but only if the last path component is not an existing non-directory file.

from https://docs.python.org/3/library/pathlib.html

    now = datetime.now()
    save_dir = 'wandb/debug/checkpoints/'+now.strftime('%y-%m-%d')
    Path(save_dir).mkdir(exist_ok=True, parents=True)

Path.stem

midi_path
# PosixPath('/home/clay/userdata/symbolic_music_tokenizing/remi_dataset_paper/evaluation')
midi_path.stem
# 'evaluation'
profile
chords & code // harmony with structure

0개의 댓글