You first need to declare an encoding, as the error messages says so clearly — it even tells you to look here for details! Your encoding is presumably gb2312
.
BTW, it would be simpler (with the same encoding declaration) to do
print u'哈哈'.encode('utf-8')
and you may not even need the encode
part, if your sys.stdout
has an encoding
attribute properly set (depends on your terminal, OS, etc).