오늘의 파이썬 궁금증 str이 어떻게 나뉜걸까..?
2022. 12. 22. 23:58ㆍTrip to Python
PLACEHOLDER = "[name]"
with open("/Users/82104/Desktop/Python Workspace/pycharm/day 24/challenge/Input/Names/invited_names.txt") as names_file:
names = names_file.readlines()
with open("/Users/82104/Desktop/Python Workspace/pycharm/day 24/challenge/Input/Letters/starting_letter.txt") as letter_file:
letter_contents = letter_file.read()
for name in names:
stripped_name = name.strip()
new_letter = letter_contents.replace(PLACEHOLDER, stripped_name)
with open(f"/Users/82104/Desktop/Python Workspace/pycharm/day 24/challenge/Output/ReadyToSend/letter_for_{stripped_name}.txt", mode="w") as completed_letter:
completed_letter.write(new_letter)
new_letter가 str인데 어떻게 자동으로 나눠서 txt 파일을 만드는 것인지 이해가 되지 않았다.
'Trip to Python' 카테고리의 다른 글
(Python) List Comprehension, Dict Comprehension 이해 (0) | 2022.12.28 |
---|---|
파이썬 Turtle Crossing 게임 만들기 (1) | 2022.12.21 |
파이썬 Pong game 만들기 (0) | 2022.12.20 |
(파이썬 OOP 이해도 높이기) 거북이 레이스 만들기 - 파이썬 좌표 개념 (0) | 2022.12.12 |
(파이썬 OOP 이해도 높이기 )퀴즈 프로그램 만들기 (0) | 2022.12.08 |