프로그래밍(programming)/Python
python idle에서 'UCS-2' codec can't encode character 가 뜰경우
윤's군
2015. 12. 27. 22:06
Python idle에러로
idle에서 4bytes 유니코드를 제대로 출력못하는 경우에 발생합니다.
1 2 | str = '\U0001F44D' print(str) | cs |
idle에서 실행하면 아래와 같이 실패합니다.
>>> str = '\U0001F44D';
>>> str
'\U0001f44d'
>>> print(str)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
print(str)
File "C:\Python34\lib\idlelib\PyShell.py", line 1347, in write
return self.shell.write(s, self.tags)
UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001f44d' in position 0: Non-BMP character not supported in Tk
pycharm이나 utf8 지원하는 콘솔에서 실행하면 잘 됩니다.