ref:
http://wklken.me/posts/2013/08/31/python-extra-coding-intro.html

note:

  • 主要分str 和 unicode两种类型。用type来查看
  • str是又unicode encode之后得到的。所以str不能encode,而unicode不能decode
  • 进来的string,全部用decode(“utf-8”)转换成unicode,然后进行处理。处理完之后。如果需要print或者f.write,则用encode(“utf-8”)就可以顺利地显示中文了