Python2 UTF-8 한글 사용

Jmnote (토론 | 기여)님의 2014년 7월 4일 (금) 20:45 판
Python UTF-8 사용
Python 한글 사용

1 오류 예시

[root@jmnote ~]# cat hello.py 
print "안녕"
[root@jmnote ~]# python hello.py
  File "hello.py", line 1
SyntaxError: Non-ASCII character '\xec' in file hello.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

2 정상 예시

[root@jmnote ~]# cat hello2.py 
# -*- coding: utf-8 -*-
print "안녕"
[root@jmnote ~]# python hello2.py
안녕

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}