프로그래밍/Python
[Python] SyntaxError: Non-ASCII character '\xeb' in file test.py on line 5, but no encoding declared;
guitarhero
2017. 10. 17. 10:25
728x90
Python 에러
SyntaxError: Non-ASCII character '\xeb' in file test.py on line 5, but no encoding declared;
# -*- coding: cp949 -*-
from bs4 import BeautifulSoup
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
한글은 코딩할때 unicode로 저장하는게 좋고
hi = u'안녕하세요'
type 함수를 통해 현재 내가 변수에 저장한 문자열이 str(아스키코드)인지 unicode인지 확인이 가능하다.
unicode로 넘어온 데이터를 변수에서 한글깨짐때문에 cp949나 utf-8로 인코딩해서 변수에 넣어 줬다면
엑셀에 한글 데이터를 집어넣을려면 unicode 방식을 이용해야 된다. 그래서 디코딩을해서 진행해 줘야 한다.
728x90