본문 바로가기
IT/Python

SyntaxError: Non-UTF-8 code starting with '\xea' in file <FilePath> but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

by 성준하이 2022. 12. 26.
반응형

파이선에서 스트링을 읽어서 파싱하는 작업 도중 다음 에러가 발생하였다.

 

syntaxError: Non-UTF-8 code starting with '\xea' in file <FilePath> but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

 

아마 encoding이 뭔가 잘못된 에러인것 같다.

 

해결법은 생각보다 간단했다.

파일 자체에서 인코딩을 인식하게 하기 위해

코드 제일 상단에 # -*- coding: utf-8 -*- 를 삽입하면 된다.

 

에러메세지에 있는 사이트를 들어가보면 더 자세히 확인이 가능하다.

 

https://peps.python.org/pep-0263/

 

PEP 263 – Defining Python Source Code Encodings | peps.python.org

PEP 263 – Defining Python Source Code Encodings Author: Marc-André Lemburg , Martin von Löwis Status: Final Type: Standards Track Created: 06-Jun-2001 Python-Version: 2.3 Post-History: Table of Contents This PEP proposes to introduce a syntax to declar

peps.python.org

 

반응형

'IT > Python' 카테고리의 다른 글

단어가 영어인지 아닌지 확인법  (8) 2022.12.29
모듈 경로 알아내기  (15) 2022.12.27
파이선 리스트 중복 제거  (26) 2022.12.13
파일 복사  (40) 2022.11.30
파이선 3.11 에 대해서  (37) 2022.11.14

댓글