본문 바로가기

Python

Day _03_04_파일 읽는 법:with open과 as

반응형

def read_4(filename):
with open(filename, 'r', encoding='utf-8')as f:
for line in f:
print(line.strip())

filename = 'Data/Poem.txt'
read_4(filename)