#encoding=utf-8
##encode 将对象按照指定编码进行编码。
##decode 将对象按照指定编码进行解码。
s="你好"
s.decode("GBK")
s.decode("GBK").encode("utf-8")
##>>> s="你好"
##>>> s.decode("GBK")
##u'\u4f60\u597d'
##>>> s.decode("gbk").encode("utf-8")
##'\xe4\xbd\xa0\xe5\xa5\xbd'
##>>>
#encoding=utf-8
##encode 将对象按照指定编码进行编码。
##decode 将对象按照指定编码进行解码。
s="你好"
s.decode("GBK")
s.decode("GBK").encode("utf-8")
##>>> s="你好"
##>>> s.decode("GBK")
##u'\u4f60\u597d'
##>>> s.decode("gbk").encode("utf-8")
##'\xe4\xbd\xa0\xe5\xa5\xbd'
##>>>
转载于:https://www.cnblogs.com/silencekt/p/3292679.html