본문 바로가기
반응형

Encoding2

SyntaxError: Non-UTF-8 code starting with '\xbf' in file 파이선에서 다음과 같은 에러가 발생했다.SyntaxError: Non-UTF-8 code starting with '\xbf' in file UTF-8 이라는 단어가 있어서 단번에 인코딩 문제구나 라고 짐작할수 있다. 해결방법은 인코딩을 변경해주면 된다. 방법 1소스 코드 맨 위에 이 코드를 삽입한다.-- coding: utf-8 --한글 인코딩 문제로 발생하는 것으로 utf-8로 인코딩한다. 방법 2필자는 vscode를 사용해서 python 작업을 하는데 오른쪽 하단에 인코딩 설정해주는 부분이 있다.그 부분을 utf-8로 설정하면 된다.참고 포스팅https://thenicesj.tistory.com/162 인코딩이란?(ascii, unicode, utf-8)개발자들은 개발을 하다보면 한글 출력부분에 있.. 2024. 4. 25.
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 파이선에서 스트링을 읽어서 파싱하는 작업 도중 다음 에러가 발생하였다. syntaxError: Non-UTF-8 code starting with '\xea' in file 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.. 2022. 12. 26.
반응형