在網上看到了mircoblog的這個web程式,用flask框架寫的,自己就在windows的環境下實現了下。
1.這個部落格系統用到了一個flask外掛叫flask_Login 裡面涉及到編碼解碼的問題 出錯的提示是:
base = unicode("%s|%s" % (request.remote_addr,request.headers.get("User-Agent")), 'utf8', errors='replace')
TypeError: decoding Unicode is not supported
查閱了下stackoverflow http://stackoverflow.com/questions/7634715/python-decoding-unicode-is-not-supported
原因寫的很清楚,可能是"%s|%s" % (request.remote_addr,request.headers.get("User-Agent")),本身已經是unicode了,沒必要用utf-8進行解碼
這個unicode的意思相當於 引數1.decode('utf-8') 得到的應該是unicode 但是若引數1本身已經是unicode的話 就沒必要解碼了。
解決方法就是