choco's story
파이썬 스터디 42 - with 키워드 본문
with 키워드
긴 프로그램을 작성할 때, 프로그램 파일이 실수로 닫히는 경우를 방지해주는 키워드
기본구조
with open(문자열: 파일 경로, 문자열: 모드) as 파일 객체:
문장
ex)
with open('with_text.txt', 'w') as file:
file.write("Hello Python Programming...!\n")
file.write("I'm studying Python text file coding\n")
file.write("It is very funny\n")


'프로그래밍 언어 공부 (Coding Study) > 파이썬 (Python) 기본' 카테고리의 다른 글
| 파이썬 스터디 44 - try except else 구문 (0) | 2024.09.22 |
|---|---|
| 파이썬 스터디 43 - try except 구문 (0) | 2024.09.22 |
| 파이썬 스터디 41 - 파일 처리 (0) | 2024.09.21 |
| 파이썬 스터디 40 - 람다(Lambda) (0) | 2024.09.21 |
| 파이썬 스터디 39 - filter() 함수 (0) | 2024.09.21 |
