2017-09-26 11 views

답변

1

플래그 옵션을 사용하면 파일 쓰기 또는 덮어 쓰기와 관련된 다양한 동작을 설정할 수 있습니다. WriteStream, 당신은 플래그 w를 전달하는 경우가있는 경우이 파일을 덮어을 만들 때 플래그 r+를 사용하는 경우이 경우, 그냥 파일을 수정하는 반면

예를 들어

는, (이것은 기본값입니다) 읽기 및 쓰기 용 파일을 실제로 열 때 존재합니다. 존재하지 않으면 오류가 발생합니다. 여기

는 플래그의 손실 거기 설명 :

'r' - Open file for reading. An exception occurs if the file does not exist. 
'r+' - Open file for reading and writing. An exception occurs if the file does not exist. 
'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists). 
'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). 
'a' - Open file for appending. The file is created if it does not exist. 
'a+' - Open file for reading and appending. The file is created if it does not exist.