2024年6月7日金曜日

Pythonでunicodeで変なエラーがでたとき

UnicodeEncodeError: 'ascii' codec can't encode character '\u2026' in position 45: ordinal not in range(128)
が出たときに下のように書いたら治った。
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')