python ascii encoding系列 遇到問題

在處理python code的時候
有時候會有

 "嗨" in string

的情況發生

就會噴 ascii can not encode 0x09之類的東西

這時候網路上有些文章說

import sys
reload(sys)
sys.setdefaultencoding("utf-8")
這在有些時候會有問題
另一種workaround是把中文字串改成
unicode("嗨","utf-8")
這樣就沒問題囉~~

留言

這個網誌中的熱門文章

google smtp好麻煩啊~

Youtube如何擁有自訂的網址

http action PUT POST使用的時機