반응형
# 메모장 저장
def sentence_to_txt(self, file_name: str, sentence: str):
save_path = os.path.join("경로를 입력해주세요", "폴더 이름")
# 폴더가 없을 시 생성
if os.path.isdir(save_path) == False:
os.mkdir(save_path)
else:
pass
# 위에서 선언한 경로에 메모장 파일을 생성함
sentence_txt = os.path.join(save_path, f"{file_name}.txt")
with open(sentence_txt, "w", encoding="UTF8") as f:
f.write(sentence)
반응형