'Code/Python'에 해당되는 글 1건

  1. 2014.12.15 Python 한글
Code/Python2014. 12. 15. 17:43

#!/usr/bin/python
# -*- coding: 949 -*-

위와 같이 949 혹은 cp949 ms949... 등과 같이 선언하면 됨.

그러나! 

ubuntu에서는 'SyntaxError: 'cp949' codec can't decode bytes in position 20-21: illegal multibyte sequence' 와 같은 에러가 발생 함.


ubuntu의 한글코드 기본값이 utf-8이므로,
파이썬 코드를 편집할 때 첫째줄에
# -*- coding:utf-8 -*-
을 추가하시면 됩니다.   (출처 : "https://kldp.org/node/81708")

Posted by Joe.C