python unicode to str and str to unicode

Posted 一天一点到

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python unicode to str and str to unicode相关的知识,希望对你有一定的参考价值。

    @staticmethod
    def unicode2str(p_unicode):
        v = p_unicode.encode(unicode-escape).decode(string_escape) if p_unicode is not None else None
        return v

    @staticmethod
    def str2unicode(p_str):
        v = p_str.decode(unicode-escape) if p_str is not None else None
        return v

 

以上是关于python unicode to str and str to unicode的主要内容,如果未能解决你的问题,请参考以下文章