파이썬

(Python) 한글 출력시 b'\xed\x95\x9c 이렇게 깨짐

danune.dev 2022. 9. 29. 23:38

encoding된 text를 바로 출력하면 이런 현상이 발생합니다 

utf-8로 decode해서 출력하면 정상출력됩니다

 

>>> text = '한글'.encode('utf-8')

>>> print(text)
b'\xed\x95\x9c\xea\xb8\x80'

>>> print(text.decode('utf-8'))
한글