728x90
별 방법을 다 시도해 보았지만 아래만큼 깔끔한 방법이 없었다.
utf-8을 설정해도 물음표로 출력되는 경우 아래의 코드 4줄을 추가하면 해결된다.
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8')
약간 코드의 길이가 늘어나는 단점이 있지만 한글이 깨지는 것보다는 낫지 않을까?
728x90