#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http 제목file 강의 중 readline예제 질문 2021-10-21 17:10작성자임주현hopedale_file=open('hopedale.txt','r')hopedale_file.readline()data=hopedale_file.readline().strip()while data.startswith('#'): data = hopedale_file.readline().strip()for data in hopedale_file: print(data.strip())hopedale_file.close() 이런식으로 코드를 작성하게 된다면 4번째 줄인 22는 이미 while문을 빠져나오면서 읽힌것이 되어 data에는 22로 저장되어 빠져나오지만 for문을 들어갈땐 5번째부터 포함이 되기 때문에 22는 안나오고 그다음줄부터 나오는 현상은 이해했습니다. 그러나 우연히 제가hopedale_file=open('hopedale.txt','r')hopedale_file.readline()data=hopedale_file.readline().strip()while data.startswith('#'): data = hopedale_file.readline().strip()for data in hopedale_file: print(data.strip())hopedale_file.close()라는 식으로 for문을 while문안에 포함을 시키니까 22부터 정상적으로 값이 출력됨을 파악했는데요. 왜 이렇게 출력이 되는지 이해를 못하겠습니다. 포함 시키는 것과 안시키는 것의 전개과정에서 어떤 차이가 발생한 것일까요ㅠㅠ? 목록수정삭제답변글쓰기 댓글 [0] 댓글작성자(*)비밀번호(*)내용(*) 댓글 등록 더보기이전[re]'file'수업 관련 문의신종민 조교2021-10-22다음[re]file 강의 중 readline예제 질문 신종민 조교2021-10-22 Powered by MangBoard | 워드프레스 쇼핑몰 망보드