我在Python 2.7中國的計劃,是給我一些問題問題與中國在python
代碼:
# -*- coding: gb2312 -*-
import sys
command = raw_input(">>> ").decode(sys.stdin.encoding)
if (command == u"你好".encode('utf-8')):
print "etc"
我得到的錯誤:
test_chinese.py:6: UnicodeWarning:Unicode等於比較無法將兩個參數轉換爲Unicode - 將它們解釋爲不相等 if(command == u「 」.encode('utf-8')):
有什麼不對嗎?
嘗試下面的代碼if(command == u「你好」):'而不是'if(command == u「你好」.encode ('utf-8')):' – Minji