[ ★ ]Study/Programming
파이썬 cp949 에러 : python UnicodeEncodeError
nroses-taek
2020. 9. 24. 11:46
반응형
윈도우 이벤트 로그 파싱하다가 txt로 뽑으려는 찰나에 아래와 같은 오류를 발견했다.
UnicodeEncodeError: 'cp949' codec can't encode character '\u200e' in position 0: illegal multibyte sequence
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
혹은
# -*- encoding: utf-8 -*-
맨 위에 둘 중 하나 추가해 주면 해결된다.
반응형