-
카테고리
-
세부 분야
프로그래밍 언어
-
해결 여부
미해결
xml open 관련 질문입니다.
18.12.06 00:48 작성 조회수 102
0
File "", line 1
with open("books.xml", "r", encoding="utf8") as books_file:
^
SyntaxError: invalid syntax
이렇게 나오는데요 왜 그런건가요?
답변을 작성해보세요.
0
Joomyung Lee
질문자2018.12.06
13주차 코딩파일입니다.
week_13_code 안에 있는 csv_read.py 파일입니다.
앞뒤에 아무 코드 없습니다.
line_counter = 0 #파일의 총 줄수를 세는 변수
data_header = [] #data의 필드값을 저장하는 list
customer_list = [] #cutomer 개별 List를 저장하는 List
with open("customers.csv", 'r') as customer_data:
이상한 부분은
f = open("customers.csv", 'r', encoding = "utf-8")
contents = f.read()
print(contents)
이런 식으로 open 을 하여 읽으면 코드가 다 실행이 됩니다.
단순히 with 와 open을 같이 쓰면 unexpected EOF 라고 뜹니다.
혹시 이런 경우는 없었나요?
0
답변 2