Python2中的Unicode

在代码中

s = "编码"
print s
$ python unicodetest.py
  File "unicodetest.py", line 1
SyntaxError: Non-ASCII character '\xe7' in file unicodetest.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
# -*- coding: utf-8 -*-
s = "编码"
print s
$ python unicodetest.py
编码

当终端编码不一致

reload(sys)
sys.setdefaultencoding("utf-8")